-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bonsoir � tous!

Petite question sur les expressions r�guli�res sous php. J'ai un petit
probl�me avec la "greediness" du processing. Voici le code:

$str = "<foo>hello there</foo>\n<foo>go there</foo>\n";
echo $str;

<foo>hello there</foo>
<foo>go there</foo>

$str1 = preg_replace("%<foo.*hello.*</foo>%Us","replaced1", $str);
echo $str1;

replaced1
<foo>go there</foo>

$str2 = preg_replace("%<foo.*go.*</foo>%Us","replaced2", $str);
echo $str2;

replaced2


Je ne comprend pas pourquoi j'obtiens 2 choses diff�rentes suivant que je fait un match du 1e tag <foo></foo> ou du 2e. L'option U est sens� d�sactiver le greediness (ce qui est bien le cas lors de la 1e substitution). Mais pour la 2e, �a ne semble pas marcher.

Quelqu'un aurait-il une id�e?

Bon week-end!

Pat
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFBslDtDdcPKzlCXVMRAkuZAJ95fVuZyBD5x0K76Lhibz/VpsiDYACgiJ87
6fCOONsUKhlCzERQ/syO8us=
=lkzx
-----END PGP SIGNATURE-----
_______________________________________________
gull mailing list
[EMAIL PROTECTED]
http://lists.alphanet.ch/mailman/listinfo/gull

Répondre à