Re: Re: Regular Expression Backreference in subpattern.

From: Date: Sun, 28 Sep 2008 17:04:32 +0000
Subject: Re: Re: Regular Expression Backreference in subpattern.
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-281076@lists.php.net to get a copy of this message
Shiplu wrote:
Sorry The previous code was wrong, Its the correct version, $x = "a b;c d;e f;"; preg_match('/(?P<keys>\w) (?P<values>\w)/',$x,$m); print_r($m); Now I am using backrefrence \1 in in ?P option like (?P<\1>\d+). and I got the error.
thought I best update for courtesy sake; I spent a good chunk of time on this yesterday, read all the regex stuff I could find, and the closest I could get was to use recursive sub patterns, however there was no way to make a named subpattern name (<keys>) be a backreference / variable.. ie <$1> <\1> <\\1> will never work. even using this method you're still going to have to combine the two arrays to get what you want ($m['keys'] with $m['values']) Regards & do let me know if you manage! Nathan ps: there may be something in the ?>&name syntax; I don't think so though..

« previous php.general (#281076) next »