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.

150 ” PCRE Extension<br />

Escaping<br />

There may be instances where you want <strong>to</strong> include literal characters in patterns that<br />

are usually interpreted as meta-characters. This can be accomplished via a \ metacharacter.<br />

<br />

N o t e that it is necessary <strong>to</strong> double-escape ” in the second example because the<br />

string ’<br />

’ is interpreted <strong>to</strong> be a single backslash by <strong>PHP</strong> whether or not it is used<br />

in a regular expression. In other cases, no escaping of ” is needed for the<br />

escape sequence <strong>to</strong> be interpreted properly.<br />

i<br />

Double Escaping<br />

F o r more information on the reasoning behind the double-escape example in this section,<br />

see http://php.net/manual/en/language.types.string.php#language.types.string<br />

and the Backslash section of http://php.net/manual/en/regexp.reference.php.<br />

Escape Sequences<br />

There are three ways <strong>to</strong> match a single character that could be one of several characters.

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

Saved successfully!

Ooh no, something went wrong!