note 20335 deleted from pcre.pattern.syntax by sniper
| From: | sniper@php.net | Date: | Tue, 30 Sep 2003 12:20:33 +0000 |
| Subject: | note 20335 deleted from pcre.pattern.syntax by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57418@lists.php.net to get a copy of this message | ||
Note Submitter: buracco@yahoo.com
----
Say you have a pattern with 3 groups and want to replace 2nd.
i.e. (\w+=")(\d+)(")
preg_replace($pattern, "\$1$replacement\$3" ,$subject)
Works fine unless $replacement starts with a number. What to do then?
p.s.
When matching,
...If the pattern continues with a digit character, then some delimiter must be used to terminate
the back reference. If the PCRE_EXTENDED option is set, this can be whitespace. Otherwise an empty
comment can be used.comment can be used...