Page 1 sur 1

RegEx [sous-masques uniques] Bug ?

Posté : 27 juil. 2016, 21:45
par carte-sd
Bonjour à tous,
Je suis sous PHP 7.0.8 et je rencontre un problème que j'ai du mal a expliquer.
Essayez ceci :

Code : Tout sélectionner

$string = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<1544><45>?aaaaaaaaaaaaaaaaa'; preg_match('#(\D+|<\d+>)*[!?]#', $string, $matches); var_dump($matches); /* array (size=2) 0 => string 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<1544><45>?' (length=41) 1 => string '<45>' (length=4) */ /* Je rajoute deux ou trois « a » après le « ? » (un seul suffit) */ $string = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<1544><45>?aaaaaaaaaaaaaaaaaaaaa'; preg_match('#(\D+|<\d+>)*[!?]#', $string, $matches); var_dump($matches); /* array (size=0) empty Pourquoi empty ? */ /* Alors que */ preg_match('#((?>\D+)|<\d+>)*[!?]#', $string, $matches); var_dump($matches); /* array (size=2) 0 => string '<1544><45>?' (length=11) 1 => string '<45>' (length=4) */
Est-ce un bug ?

PS : Désolé pour les 3 edit je me suis embrouillé.

Re: RegEx [sous-masques uniques] Bug ?

Posté : 27 juil. 2016, 22:02
par or 1
https://regex101.com/r/tB6zM6/1 retourne :
"Catastrophic backtracking
Catastrophic backtracking has been detected and the execution of your expression has been halted. "

il faut essayer de faire les choses différemment.