note 84170 added to function.preg-replace

From: Date: Tue, 01 Jul 2008 23:36:07 +0000
Subject: note 84170 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-141052@lists.php.net to get a copy of this message
@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' ---- Server IP: 83.137.20.135 Probable Submitter: 82.171.70.124 ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- https://master.php.net/note/edit/84170 Del: integrated -- https://master.php.net/note/delete/84170/integrated Del: useless -- https://master.php.net/note/delete/84170/useless Del: bad code -- https://master.php.net/note/delete/84170/bad+code Del: spam -- https://master.php.net/note/delete/84170/spam Del: non-english -- https://master.php.net/note/delete/84170/non-english Del: in docs -- https://master.php.net/note/delete/84170/in+docs Del: other reasons-- https://master.php.net/note/delete/84170 Reject -- https://master.php.net/note/reject/84170 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#141052) next »