note 84170 deleted from function.preg-replace by mgf
| From: | mgf@php.net | Date: | Wed, 02 Jul 2008 10:00:51 +0000 |
| Subject: | note 84170 deleted from function.preg-replace by mgf | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-141060@lists.php.net to get a copy of this message | ||
Note Submitter: jasper [at] ho{remove this}rn [dot] nl
----
@Santosh: the function works just as expected, you only have to know how to find the right number
for the brackets.
What you do is first take the whole message, that's 0. Then start at the beginning of you regex
- the first opening brackets is your 1, the second is 2 and so on. Note that this is not the first
and second to be filled, but the first and second from the start. Keeping that in mind your output
is completely logical. Also, when keeping that in mind you can always rewrite your expression as
such that it works (it just isn't always easy).
In the provided example the following regex would be what you were looking for:
'
((A|B|C).+?(\1))e'
This can again be changed to the shorter:
'([A-C]).+?(\1)e'