note 37343 added to function.preg-match
| From: | nospam at 1111-internet dot com | Date: | Tue, 11 Nov 2003 17:29:30 +0000 |
| Subject: | note 37343 added to function.preg-match | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-60252@lists.php.net to get a copy of this message | ||
Backreferences (ala preg_replace) work within the search string if you use the backslash syntax.
Consider:
<?php
if (preg_match("/([0-9])(.*?)(\\1)/", "01231234", $match))
{
print_r($match);
}
?>
Result: Array ( [0] => 1231 [1] => 1 [2] => 23 [3] => 1 )
This is alluded to in the description of preg_match_all, but worth reiterating here.
----
Manual Page -- http://www.php.net/manual/en/function.preg-match.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+37343
Delete -- http://master.php.net/manage/user-notes.php?action=delete+37343&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+37343&report=yes
Search -- http://master.php.net/manage/user-notes.php