tags:

views:

77

answers:

1

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
+4  A: 

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
Paolo Bergantino
Oh cool. I should have read the documentation a little more closely.Thank you.
Tyler
Wow that works beautifully! Thanks.
Tyler