Re: Regular Expression Backreference in subpattern.
| From: | Al | Date: | Sat, 27 Sep 2008 17:17:39 +0000 |
| Subject: | Re: Regular Expression Backreference in subpattern. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-281051@lists.php.net to get a copy of this message | ||
Shiplu wrote:
The string is "<td>charge</td><td>100</td>". I want and array( "charge"=>100). I am using this regular expression, '/<td>([^<]+)<\/td><td>(?P<\1>\d+)<\/td>/'. But its not working.. I get this error., PHP Warning: preg_match(): Compilation failed: syntax error after (?P at offset 25 in E:\src\php\WebEngine\- on line 4 any idea? $pattern="%<td>(\w*)</td><td>(\d+)</td>%";$str="<td>charge</td><td>100</td>"; preg_match($pattern, $str, $matches); Make a new array with $new= array($matches[1] => $matches[2]);