Forum Moderators: coopster
In java, I could do this in about 5 mins, String tokenize, then search through and isInteger everything to find the numbers.
PHP is a good scripting language, and I'm almost positive Perl can do it, which means php should have some type of option to do it.
Good luck on finding it, let me know if you do
the 0-9 is to look for integers, but what is the \ or the ^ or the []. how do you use them so I can understand
preg_replace() functions. I looked on the web and found lots of examples on how to use this function but none explained the special characters.
Thank you for your help guys
M.
$newvar = preg_replace('/[^0-9]/',"","123 successful");
The first string is saying "find anything that *isn't* in the char range 0-9. The square brackets "[]" indicate that it should try and match any char in the brackets, and the caret "^" says to use the inverse of what is in the brackets.
Second string says replace it with an empty string. =)