Je souhaite traiter des chemins de fichiers.. j'ai trouvé un comportement qui me semble anormal dès qu'il y a certains chiffres après. Qui peut m'expliquer ou se trouve mon erreur dans mon tout petit motif de détection d'antislash ('[\\\]') ?
Merci aux posteurs éclairés et bienveillants qui pourront m'aider.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 //$str_chaine_avec_antislash="abcde\fghij.php"; // renvoi "found" //$str_chaine_avec_antislash="abcde\ fghij.php"; // renvoi "found" //$str_chaine_avec_antislash="abcde\0fghij.php"; // renvoi "NOT found" //$str_chaine_avec_antislash="abcde\1fghij.php"; // renvoi "NOT found" //$str_chaine_avec_antislash="abcde\2fghij.php"; // renvoi "NOT found" //$str_chaine_avec_antislash="abcde\3fghij.php"; // renvoi "NOT found" //$str_chaine_avec_antislash="abcde\4fghij.php"; // renvoi "NOT found" //$str_chaine_avec_antislash="abcde\5fghij.php"; // renvoi "NOT found" //$str_chaine_avec_antislash="abcde\6fghij.php"; // renvoi "NOT found" //$str_chaine_avec_antislash="abcde\7fghij.php"; // renvoi "NOT found" //$str_chaine_avec_antislash="abcde\8fghij.php"; // renvoi "found" //$str_chaine_avec_antislash="abcde\9fghij.php"; // renvoi "found" //--- tester si présence d'un antislash dans la chaine if(preg_match('[\\\]',$str_chaine_avec_antislash)==1) echo "\n found \n"; else echo "\n NOT found \n";![]()
Partager