After some Googling I found the following:
Code: Select all
return preg_replace('/[\p{Z}]+$/u', '', $value);
While it works it also seems to ignore new lines so I guess newlines in unicode are not consider whitespace.
--- END EDIT ---
I found the following article:
http://www.regular-expressions.info/unicode.html
Really helped clear things up.
The only problem I see now is that instead of using trim() I should probably use Regex to strip trailing whitespace using something like:
Code: Select all
// Filter trailing whitespace
$subject = preg_replace('/\p{Z}/', '', $subject);
I believe this will stripp *all* whitespace though and all I really want to do is trim trailing whitespace...so how do you start at the end of a string and strip backwards until a non-whitespace charatcer is found?
Pardon all the questions, but Unicode and regex are two areas which I need to really brush up on. The problem with regex is it is such a write once use over and over again, so unless you constantly use it, you forget it, which is what I experience.
Cheers,
Alex