I can't seem to find a function that captures and returns a regex'ed string.
$string = "hello123!";
$string = regexfunction($string, "/([0-9]*)/");
echo $string;
Prints
123
I can't seem to find a function that captures and returns a regex'ed string.
$string = "hello123!";
$string = regexfunction($string, "/([0-9]*)/");
echo $string;
Prints
123
You want to use preg_match
for this, although the syntax will be slightly different:
$string = "hello123!";
preg_match("/[0-9]+/", $string, $matches);
print $matches[0]; // 123