[Mono-dev] Regex and Unicode

Kornél Pál kornelpal at gmail.com
Wed Jul 9 10:31:22 EDT 2008


Hi,

The following character class names are supported by .NET Framework:
http://msdn.microsoft.com/en-us/library/20bw873z.aspx

You should try:
\p{L}

I think that this is implemented by Mono as well.

Note that http://www.regular-expressions.info/posixbrackets.html is not 
an authentic source for documentation either on MS.NET or on Mono.

Kornél

Vladimir Giszpenc wrote:
> Hello list members,
> 
>  
> 
> Since .Net regular expressions don't do POSIX, I replace POSIX character 
> classes by Unicode ones.  See 
> http://www.regular-expressions.info/posixbrackets.html for the 
> translation table I used.
> 
>  
> 
> I ran into a problem with
> 
> POSIX       Description             ASCII       Unicode
> 
> [:alpha:]  Alphabetic characters  [a-zA-Z]    \p{L&}
> 
>  
> 
> The problem occurs in .Net too so you might choose not to fix it and I 
> would understand.  I hope however, you can fix it (and get MS to do the 
> same).
> 
>  
> 
> The \p{L&} regular expression throws an exception because the ampersand 
> is neither a character nor a close brace. 
> 
>  
> 
> System.ArgumentException: parsing "\p{L&}" - Incomplete \p{X} character 
> escape.
> 
> Parameter name: \p{L&}
> 
>   at System.Text.RegularExpressions.Syntax.Parser.ParseUnicodeCategory 
> () [0x000a8] in 
> /tmp/monobuild/build/BUILD/mono-1.9.1/mcs/class/System/System.Text.RegularExpressions/parser.cs:796 
> 
> 
>> >> Rest of exception clipped <<<
> 
>  
> 
>  
> 
> *using *System;
> 
> *using *System.Text.RegularExpressions;
> 
>  
> 
> *namespace *test
> 
> {
> 
>       class MainClass
> 
>       {
> 
>             *public *static void *Main*(string[] args)
> 
>             {
> 
>                   Regex r = *new **Regex*(@"\p{L&}"); //running this 
> code will throw an exception
> 
>             }
> 
>       }
> 
> }
> 
>  
> 
> Since this might be by design, I am not using bugzilla.  I hope someone 
> can tell me how this is supposed to work first.  Also, I am not looking 
> for a workaround, as I have one.  This is more of an FYI.
> 
>  
> 
> Thanks,
> 
>  
> 
> Vlad
> 
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list


More information about the Mono-devel-list mailing list