03.02.2014 Views

php|architect's Guide to Web Scraping with PHP - Wind Business ...

php|architect's Guide to Web Scraping with PHP - Wind Business ...

php|architect's Guide to Web Scraping with PHP - Wind Business ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

146 ” PCRE Extension<br />

Alternation<br />

It’s possible <strong>to</strong> check for multiple expressions simultaneously in a single pattern, also<br />

called alternation, using the pipe meta-character |.<br />

<br />

N o t e that the ˆ and $ are not implicitly applied <strong>to</strong> all expressions in an alternation;<br />

they must be used explicitly for each expression.<br />

<br />

The first example returns 1 because ’abar’ contains ’bar’ since , ˆ is not applied <strong>to</strong><br />

that expression in the pattern. The second example does apply ˆ <strong>to</strong> ’bar’ and, since<br />

’abar’ begins <strong>with</strong> neither ’foo’ nor ’bar’ it returns , 0.<br />

R e p e t i t i o n and Quantifiers<br />

P a r t of a pattern may or may not be present, or may be repeated a number of times.<br />

This is referred <strong>to</strong> as repetition and involves using meta-characters collectively referred<br />

<strong>to</strong> as quantifiers.<br />

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

Saved successfully!

Ooh no, something went wrong!