March 15th, 2013, 05:49 AM
Find the first number in a string?
I need to split a string when it encounters a number.. and split everything after it .
Explode doesn't work cause the number can change. any regular expression hero's ? thanks
March 15th, 2013, 06:04 AM
$res = preg_split('/\d+/', 'Split -->42<-- here 4', 2);
March 15th, 2013, 06:13 AM
Thank you for the fast reply! this works. But is it also possible to split and keep everything after that number?
Originally Posted by Jacques1
as in "Something 2euro" and i want to seperate the "something" and the "2euro"
Regular expressions are so hard!
March 15th, 2013, 06:17 AM
So you wanna keep the number? When you say "everything after the number", I read that as "number not included".
$res = preg_split('/(?=\d+)/', 'Something 2euro', 2);