Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Setting locale for java.util.regex at runtime

Reply
Thread Tools

Setting locale for java.util.regex at runtime

 
 
Alex Polite
Guest
Posts: n/a
 
      06-05-2004
"\w" doesn't match wordchars outside of [A-Za-z].

I suppose that this is in some way controlled by locale.

Is there any way to make this localesetting at runtime?

alex

--
Alex Polite
http://polite.se
 
Reply With Quote
 
 
 
 
Alan Moore
Guest
Posts: n/a
 
      06-05-2004
On 5 Jun 2004 20:52:22 GMT, Alex Polite <> wrote:

>"\w" doesn't match wordchars outside of [A-Za-z].
>
>I suppose that this is in some way controlled by locale.
>
>Is there any way to make this localesetting at runtime?
>
>alex


The java.util.regex package is not locale-senistive at all. The
character-class shorthands (\w, \d, \s) and POSIX character classes
(\p{Alpha}, \p{Digit}, etc.) only ever match ASCII characters. If you
want to match non-ASCII characters, you have to use Unicode blocks
like \p{InGreek}, or categories like \p{IsLetter} (which can be
shortened to \pL).

Oddly enough, the word-boundary construct, \b, works with *all*
Unicode letters and digits, not just the ASCII ones. That makes sense
when I think about how frustrating it would be if it didn't, but it
makes it seem that much stranger that \w, \d and \s are limited to the
ASCII range.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: ***locale.Error: unsupported locale setting*** Vlastimil Brom Python 0 12-09-2010 11:52 PM
Module locale throws exception: unsupported locale setting Sibylle Koczian Python 2 11-20-2010 12:52 PM
Changing Locale setting at runtime napo Java 13 09-23-2008 07:28 PM
Setting locale at runtime Torsten Bronger C Programming 3 04-11-2005 11:30 PM
i18n problem, involving Locale.getDisplayLanguage and Locale.getDisplayCountry Maurice Hulsman Java 1 07-25-2004 06:11 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57