Re: how does this regular expression works
| From: | Richard Quadling | Date: | Thu, 14 Jul 2011 10:27:54 +0000 |
| Subject: | Re: how does this regular expression works | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-47924@lists.php.net to get a copy of this message | ||
On 13 July 2011 14:04, Shahriyar Imanov <shehi@imanov.name> wrote:
> \<head.*?\>(?P<head_tag_innerHTML>.*?)\<\/head\>
<head.*?>(?P<head_tag_innerHTML>.*?)</head>
Options: case insensitive; ^ and $ match at line breaks
Match the characters “<head” literally «<head»
Match any single character that is not a line break character «.*?»
Between zero and unlimited times, as few times as possible,
expanding as needed (lazy) «*?»
Match the character “>” literally «>»
Match the regular expression below and capture its match into
backreference with name “head_tag_innerHTML”
«(?P<head_tag_innerHTML>.*?)»
Match any single character that is not a line break character «.*?»
Between zero and unlimited times, as few times as possible,
expanding as needed (lazy) «*?»
Match the characters “</head>” literally «</head>»
Created with RegexBuddy
Escaping < > ? at the wrong time is simply a redundancy. Learning when
to escape is just like learning a new language.
You only need to escape anything if you need it to be a literal character.
e.g.
something.html vs something\.html
--
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea