Home Download Buy Blog Forum Support

Locale-aware regular expressions

Locale-aware regular expressions

Postby kofkof on Wed Jan 09, 2013 7:21 pm

Hello,

The \w and similar character classes ([a-z], [[:alpha:]], [[:word:]], etc.) are not locale-aware in the Find/Replace panel. For example, on my french computer, \w+ correctly matches "abcde" but not "àbcdé". I have to manually type the following pattern instead [a-zàáâãäçèéêëìíîïòóôõöùúûüÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜŸ]+.

Does anyone know of a way to make ST take my locale into account? According to what I read, ST uses the Boost library for regular expressions. There seems to exist a collate flag for this purpose, but I don't know how/where to set it in ST.

Thanks for any help
(ST2 build 2220 on Mac OS 10.7)
kofkof
 
Posts: 7
Joined: Thu Nov 01, 2012 5:03 pm

Re: Locale-aware regular expressions

Postby prmaple on Thu Jan 10, 2013 9:46 am

interesting, I can use \w to match Chinese characters. Did you turn the regex option on?
Find me
HTML5 Games: SNAKE! Tetris!
prmaple
 
Posts: 82
Joined: Sun Dec 25, 2011 11:06 am
Location: Melbourne

Re: Locale-aware regular expressions

Postby kofkof on Thu Jan 10, 2013 10:19 am

Thanks for your answer, prmaple. Chinese characters won't match with \w here, I've just tested it.

Did you turn the regex option on?

If you mean the ".*" button in the Find panel, yes, of course.
kofkof
 
Posts: 7
Joined: Thu Nov 01, 2012 5:03 pm

Re: Locale-aware regular expressions

Postby svenax on Thu Jan 10, 2013 10:24 am

Hmm, you are right. Swedish characters (åäö) don't match for me, even though my region locale is set to Swedish. That's annoying.
svenax
 
Posts: 154
Joined: Tue Dec 20, 2011 12:47 pm

Re: Locale-aware regular expressions

Postby kofkof on Fri Jan 11, 2013 8:46 am

Thanks svenax, at least I am not the only one with this problem.

Still, I'd like to solve it :-). Any idea, anyone? Should I report a bug?
kofkof
 
Posts: 7
Joined: Thu Nov 01, 2012 5:03 pm

Re: Locale-aware regular expressions

Postby svenax on Fri Jan 11, 2013 9:40 pm

kofkof wrote:Thanks svenax, at least I am not the only one with this problem.

Still, I'd like to solve it :-). Any idea, anyone? Should I report a bug?


Yes, please do. This is most likely a bug, unless Jon has a good explanation. I'd imagine using locale-aware regular expressions is slower, so maybe that's the reason.

Apart from that, there's nothing that you or I can do about it.
svenax
 
Posts: 154
Joined: Tue Dec 20, 2011 12:47 pm

Re: Locale-aware regular expressions

Postby kofkof on Mon Jan 14, 2013 2:22 pm

Done.
Thank you!
kofkof
 
Posts: 7
Joined: Thu Nov 01, 2012 5:03 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 37 guests