11.01.2015 Views

Initiation aux expressions régulières en PHP

Initiation aux expressions régulières en PHP

Initiation aux expressions régulières en PHP

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Initiation</strong> <strong>aux</strong> <strong>expressions</strong> <strong>régulières</strong> <strong>en</strong> <strong>PHP</strong> par Guillaume Rossolini<br />

Décomposition de la regex : []<br />

#^http$# => La chaîne "http".<br />

#http$# => La chaîne "http" <strong>en</strong> fin de chaîne.<br />

#^http# => La chaîne "http" <strong>en</strong> début de chaîne.<br />

Tester ce script<br />

N. B. : J'ai pris soin d'utiliser un délimiteur différ<strong>en</strong>t de la barre oblique, dans la mesure où elle se trouve dans le<br />

masque ($pattern). Sans cela, il aurait fallu échapper la barre oblique, or je préfère simplifier la lecture de la regex.<br />

Il y a bi<strong>en</strong> sûr des équival<strong>en</strong>ces tant que nous cherchons une sous chaîne fixe :<br />

Simulation d'ancrage de début ^<br />

<br />

Tester ce script<br />

Simulation d'ancrage de fin $<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!