Re: preg for unicode strings?
| From: | Andy Pieters | Date: | Sun, 06 Nov 2005 06:59:18 +0000 |
| Subject: | Re: preg for unicode strings? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-225201@lists.php.net to get a copy of this message | ||
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 fails.
Any ideas?
With kind regards
Andy
On Sunday 06 November 2005 02:11, Niels Ganser wrote:
> 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 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 regards
> >
> >
> > Andy
--
Now listening to Top! Radio Live www.topradio.be/stream on amaroK
Geek code: www.vlaamse-kern.com/geek
Registered Linux User No 379093
If life was for sale, what would be its price?
www.vlaamse-kern.com/sas/ for free php utilities
--
Attachment: [application/pgp-signature]
Attachment: [application/pgp-signature]