On Sat, November 5, 2005 3:02 pm, Andy Pieters wrote:
Hi List
I am doing some data validation and the following regexp fails
[\W]
When using characters like £ or â¬
Obviously because they are technically more then one character, even
though
they are only displayed as one.
The script
Andy,
try that one: /^[a-zA-Z]{3}|\p{Sc}$/u
You don't want to put \p{Sc} in square brackets as \p{Sc} itself already
is a character class. Umm.. Kinda don't make myself clear here, do I?
You just don't want to, it's 5am in the morning here I gotta go to the
next bed ;p
Regards,
Niels
Andy
Hi List
I am doing some data validation and the following regexp fails
[\W]
When using characters like £ or €
Obviously because they are technically more then one character, even though
they are only displayed as one.
The script is encoded in UTF-8
Anybody know a fix for this?
With kind
On 11/5/05, Andy Pieters [EMAIL PROTECTED] wrote:
I am doing some data validation and the following regexp fails
[\W]
When using characters like £ or €
The script is encoded in UTF-8
Are you using the 'u' modifier to put PCRE in utf-8 mode?
preg_match( '/\W/u', $text);
-robin
Andy,
you might want to check out
http://www.regular-expressions.info/unicode.html
Please note two things while using the described syntax:
1. You have to additionally use the u modificator.
2. While \p{Ll} for instance works in PHP, \p{Lowercase_Letter} doesn't.
Regards,
Niels
Hi List
I
Hi
Thank you for your reply.
My regexp was
/^([a-zA-Z]{3,}|[\W])/
Meaning match any string that is either
3 letters
or
1 word character
I'd like to change this to
3 letters
or
1 currency character
So I changed the regexp accordingly
/^([a-zA-Z]{3,}|[\p{Sc}])/u
And I tested with £
but it
6 matches
Mail list logo