...

View Full Version : Regex question



MattF
12-07-2010, 10:16 PM
Is there any way, with a regex, to capture a pattern and use that match within the regex itself? Something along the lines of:



~(one|two|three)some other text here(this part here should match the captured pattern, rather than just specifying one|two|three again)~



Cheers muchly.

kbluhm
12-07-2010, 10:26 PM
What you're looking for is a back reference:
http://www.php.net/manual/en/regexp.reference.back-references.php

~(one|two|three)some other text here\1~

MattF
12-07-2010, 10:58 PM
Cheers. :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum