J'ai un texte:Expression régulière pour ignorer une virgule optionnelle
$test = <<<START
DOTHIS themsp1
@theint = 431,
@theText = "%dumdum%",
@operator = 'ANY',
@crossCheck = 'PLUS'
START;
Le filtre:
$regEx = '/@(.*)=(.*)[,]*?/';
preg_match_all($regEx,$test,$vars,PREG_SET_ORDER);
print_r($vars);
La sortie:
Array
(
[0] => Array
(
[0] => @theint = 431,
[1] => theint
[2] => 431,
)
[1] => Array
(
[0] => @theText = "%dumdum%",
[1] => theText
[2] => "%dumdum%",
)
[2] => Array
(
[0] => @operator = 'ANY',
[1] => operator
[2] => 'ANY',
)
[3] => Array
(
[0] => @crossCheck = 'PLUS'
[1] => crossCheck
[2] => 'PLUS'
)
)
Je ne veux pas des virgules ou la espace dans la sortie :(.. Le problème est que les virgules sont facultatives;
Merci .. Cela fonctionne :) – Stewie