[Mono-devel-list] Class Regexp misbehavior

Aleksandar Dezelin dezelin at gmail.com
Wed Feb 23 07:37:16 EST 2005


This snippet throws an exception:

		private static string GetProtocol(string url)
		{
			// Extract version information
			Regex r = new Regex(@"^(?<proto>\w+)://[^/]+?(?<port>:\d+)?/");
			return r.Match(url).Result("$(proto)$port");
		}

The thrown exception:

Unhandled Exception: System.ArgumentException: Bad replacement pattern.
in [0x00129] (at
/home/skynet/farm/mono-trunk/mono-1.1.4/mcs/class/System/System.Text.RegularExpressions/replace.cs:138)
System.Text.RegularExpressions.ReplacementEvaluator:CompileTerm
(string,int&)
in [0x0003d] (at
/home/skynet/farm/mono-trunk/mono-1.1.4/mcs/class/System/System.Text.RegularExpressions/replace.cs:74)
System.Text.RegularExpressions.ReplacementEvaluator:Compile (string)
in [0x0001a] (at
/home/skynet/farm/mono-trunk/mono-1.1.4/mcs/class/System/System.Text.RegularExpressions/replace.cs:48)
System.Text.RegularExpressions.ReplacementEvaluator:.ctor
(System.Text.RegularExpressions.Regex,string)
in [0x00007] (at
/home/skynet/farm/mono-trunk/mono-1.1.4/mcs/class/System/System.Text.RegularExpressions/replace.cs:41)
System.Text.RegularExpressions.ReplacementEvaluator:Evaluate
(string,System.Text.RegularExpressions.Match)
in [0x00002] (at
/home/skynet/farm/mono-trunk/mono-1.1.4/mcs/class/System/System.Text.RegularExpressions/match.cs:149)
System.Text.RegularExpressions.Match:Result (string)
in [0x0001d] (at
/home/skynet/work/c#/repconvert/src/ReportConvertor/ReportConvertor.cs:199)
TemplateConvertor.ReportConvertor:GetVersionNumber ()
in [0x00005] (at
/home/skynet/work/c#/repconvert/src/ReportConvertor/ReportConvertor.cs:205)
TemplateConvertor.ReportConvertor:PrintCopyright ()
in [0x00000] (at
/home/skynet/work/c#/repconvert/src/ReportConvertor/ReportConvertor.cs:107)
TemplateConvertor.ReportConvertor:Main (string[])

This perfectly 
Is Mono class Regex compatible with .NET class Regex?

Cheers,
Aleksandar Dezelin

-- 
Linux is like wighwam, no windows no gates and apache inside...



More information about the Mono-devel-list mailing list