Ungreedy = Non gourmand.
En gros, je te donne un code :
{switch name="toto"}tototutu{/switch}tralalala{switch name="tata"}tatatutu{/switch}
Si tu fait la regex suivante :
`\{switch name="([a-zA-Z0-9]*)"}(.*)\{/switch}`si
il te retournera :
Citation
array( [0] => array(
[0] => {switch name="toto"}tototutu{/switch}tralalala{switch name="tata"}tatatutu{/switch},
[1] => toto"}tototutu{/switch}tralalala{switch name="tata,
[2] => tatatutu
))
Mais si tu utilises le mode Ungreedy d'une des 2 façons suivantes :
`\{switch name="([a-zA-Z0-9]*?)"}(.*?)\{/switch}`si
`\{switch name="([a-zA-Z0-9]*)"}(.*)\{/switch}`siU
il te retournera :
Citation
array(
[0] => array(
[0] => {switch name="toto"}tototutu{/switch},
[1] => toto,
[2] => tototutu
)
[1] => array(
[0] => {switch name="tata"}tatatutu{/switch},
[1] => tata,
[2] => tatatutu
)
)
Ou un truc du genre.
Tu vois la différence ?
En plus, le mode Ungreedy allege le processeur de regex ^^