开发者

Problem with regular expressions in MonoTouch

开发者 https://www.devze.com 2023-02-15 19:59 出处:网络
I have a problem with regular expressions in my MonoTouch application. It seems that RegexOptions.CultureInvariant is ignored, and expressions are always evaluated using the device default cul开发者_S

I have a problem with regular expressions in my MonoTouch application. It seems that RegexOptions.CultureInvariant is ignored, and expressions are always evaluated using the device default cul开发者_StackOverflow社区ture. Here is a sample:

Regex rx_I = new Regex(@"II", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
Regex rx_i = new Regex(@"ii", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);

string aString = "Ii";

Match match;

match=rx_I.Match(aString);
if(match.Success){
    Console.WriteLine(match.Value);
}

match=rx_i.Match(aString);
if(match.Success){
    Console.WriteLine(match.Value);
}

When 'Region Format' is set to 'United States', both matches are successful. If it is set to 'Turkey', they both fail (because uppercase 'i' is not 'I' and lowercase 'I' is not 'i' in Turkish language). I expected that setting RegexOptions.CultureInvariant would fix this, but apparently it doesn't.

Am I doing anything wrong?

Thanks

0

精彩评论

暂无评论...
验证码 换一张
取 消