473,320 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

setlocale and regular expressions

R
Hi everybody.

I've got a problem with setting locale and regular expression.

I can set them without any trouble - I'm using LC_ALL category.

In Perl setting locale LC_CTYPE works also with regex but I was trying
to apply simple pattern [a-z] for polish characters just like this:

setlocale(LC_ALL, 'pl_PL');

// testing purposes
//$locale_info = localeconv();
//print_r($locale_info);
//echo strftime("%A %e %B %Y", mktime(0, 0, 0, 16, 6, 2005));

if (preg_match('/^[a-z]{2,10}$/', 'aezztest'))
{
echo 'works ;-)';
}

Maybe I'm doing sth wrong?
Has anyone succeeded in using locale and regex?
'locale -a' gives me also pl_PL.iso88592 - but when I use it I get the
same result as pl_PL.

thanks in advance for any help
best regards
R

Jul 17 '05 #1
3 2503
R
if (preg_match('/^[a-z]{2,10}$/', 'aezztest'))
^^^^ wow google did some
magic here ;-)
polish characters
meant to be here (in place of 'aezztest'

what ever ;-) the problem is that this regex isn't working...

Jul 17 '05 #2
R <ru******@poczta.onet.pl> wrote:
if (preg_match('/^[a-z]{2,10}$/', 'aezztest'))
^^^^ wow google did some
magic here ;-)
polish characters
meant to be here (in place of 'aezztest'
Just in case you didn't know: Google's G2 thingy is extremly borken.
what ever ;-) the problem is that this regex isn't working...


That's because [a-z] matches is the equivalanet to [\x61-\x7a]

If you want to match lowercase extended characters in iso8859-2
encoding, you need to generate a character class like:
[\xb1\xb3\xb9-\xbc]
(and lots more I guess).

Jul 17 '05 #3
R
so the conclusion is:

Perl's locale != PHP's locale

if in Perl polish locale is set, [a-z] matches both (all) characters:
latin and polish

Maybe if PHP uses PCRE it also should use locale when matching
patterns?
It would be extremely useful.

cheers
R

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make...
2
by: Sehboo | last post by:
Hi, I have several regular expressions that I need to run against documents. Is it possible to combine several expressions in one expression in Regex object. So that it is faster, or will I...
4
by: Együd Csaba | last post by:
Hi All, I'd like to "compress" the following two filter expressions into one - assuming that it makes sense regarding query execution performance. .... where (adate LIKE "2004.01.10 __:30" or...
7
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
3
by: a | last post by:
I'm a newbie needing to use some Regular Expressions in PHP. Can I safely use the results of my tests using 'The Regex Coach' (http://www.weitz.de/regex-coach/index.html) Are the Regular...
25
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
1
by: Allan Ebdrup | last post by:
I have a dynamic list of regular expressions, the expressions don't change very often but they can change. And I have a single string that I want to match the regular expressions against and find...
13
by: Wiseman | last post by:
I'm kind of disappointed with the re regular expressions module. In particular, the lack of support for recursion ( (?R) or (?n) ) is a major drawback to me. There are so many great things that can...
12
by: FAQEditor | last post by:
Anybody have any URL's to tutorials and/or references for Regular Expressions? The four I have so far are: http://docs.sun.com/source/816-6408-10/regexp.htm...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.