Doesn't work with replace , only useful for match in php
$test="yet another test";
preg_match('/(?P<word>t[^s]+)/',$test,$matches);
var_dump($matches['word']);
answered Aug 7, 2011 at 7:23
Dreaded semicolonDreaded semicolon2,31411 gold badge2929 silver badges4444 bronze badges
5According documentation
PHP 5.2.2 introduced two alternative syntaxes
(?<name>pattern)
and(?'name'pattern)
So you'll get same result using:
<?php
preg_match('/(?P<test>.+)/', $string, $matches); // basic syntax
preg_match('/(?<test>.+)/', $string, $matches); // alternative
preg_match("/(?'test'.+)/", $string, $matches); // alternative
answered Nov 22, 2017 at 11:41
Start asking to get answers
Find the answer to your question by asking.
Ask questionExplore related questions
See similar questions with these tags.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4