Reputation: 614
I was trying to use preg_replace on a string but I obtain a wrong result.
$string = "Da venerdì 26 agosto a lunedì 5 settembre 2011";
$string = preg_replace('/\p{L}+/s','',$string);
should return " 26 5 2011 " but it returns " ¬ 26 ¬ 5 2011 "
*note in my local php server on Windows XP all works fine but in my remote php server on Debian it retunrs me the wrong string
Can you help me?
Upvotes: 1
Views: 85
Reputation: 11087
You want to extract number from the string from what i see.
preg_replace("/[\s]+/", ' ', preg_replace('/[^0-9\s]/',' ',$string));
to remove anything non-number from the string, and leave only one separator space between numbersUpvotes: 2