WeirdMystery Posted May 20, 2010 Share Posted May 20, 2010 Hello, could anyone provide me with a regex that gets the last numbers of a string. Example... "The Useless Piece of Trash - Newly Updated - 22 More Items! - 224 Players" or "The Useless Piece of Trash - OLD - Go To New Game - 22 Players" I want to get "22 Players". Thanks... Quote Link to comment Share on other sites More sharing options...
cags Posted May 21, 2010 Share Posted May 21, 2010 Do you want the last number in the string (22) as you originally stated, or do you actually want "22 Players" as you stated at the end? preg_match('#([0-9]+[^0-9]*)$#', $input, $out); print_r($out); Quote Link to comment Share on other sites More sharing options...
salathe Posted May 21, 2010 Share Posted May 21, 2010 As well as what cags is asking, will the string always end with " Players" ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.