Code : Tout sélectionner
if(preg_match_all("/[^\\]([eE!])\./",$math,$match_math))
{
foreach ($match_math as $v1_math) {
foreach ($v1_math as $c_math=>$v2_math) {
$replacement_math = "<font color='purple'>".$v2_math."</font>";
$math = str_replace($v2_math, $replacement_math, $math);
}
}
}
Code : Tout sélectionner
$chaine_de_test="!. \!. e. \e. E. \E.";
preg_match_all("/[eE!]\./",$chaine_de_test,$matches);
$math = var_dump($matches);
Code : Tout sélectionner
$chaine_de_test="!. \!. e. \e. E. \E.";
preg_match_all("/[^\\]([eE!]\.)/",$chaine_de_test,$matches);
$math = var_dump($matches);
$chaine_de_test='!. \!. e. \e. E. \E.';
preg_match_all("/(?:^|[^\\\])([!eE]\.)/",$chaine_de_test,$matches);
$math = var_dump($matches);
qui donne :
Code : Tout sélectionner
array (size=2)
0 =>
array (size=3)
0 => string '!.' (length=2)
1 => string ' e.' (length=3)
2 => string ' E.' (length=3)
1 =>
array (size=3)
0 => string '!.' (length=2)
1 => string 'e.' (length=2)
2 => string 'E.' (length=2)Code : Tout sélectionner
if(preg_match_all("/(?:^|[^\\\])([!eE]\.)/",$math,$match_math))
{
foreach ($match_math[0] as $v1_math) {
$replacement_math = "<font color='purple'>".$v1_math."</font>";
$math = str_replace($v1_math, $replacement_math, $math);
$replacement_math = str_replace(".", "", $v1_math);
$math = str_replace($v1_math, $replacement_math, $math);
}
}