php regex via using preg_match -


i have variable $play made of characters , numbers. example:

$play = "blah05"

how use preg_match() 05? $regexp correct?

$regexp = "/^[^0-9]/"; if (preg_match($regexp, $play, $matches)) {    echo "matches[0]"; } 

if want numbers end, regexp should this:

$regexp = '/(\d+)$/';

if want numbers anywhere in string:

$regexp = '/(\d+)/';

and var_dump($matches); see results , choose option best you.

if (preg_match($regexp, $play, $matches)) {    var_dump($matches); } 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -