Problem with regular expressions in MonoTouch
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
精彩评论