GenerateRandomString(RegEx) doesn't parse conditional backrefs?

May 19, 2011 at 6:48 PM

So I have the following Regular Expression:

           Regex urlRegex = new Regex(@"(?<fullUrl>(?<scheme>http://|https://)(?<host>[a-z0-9.]*)(?<relativeMayFollow>/){0,1}(?(relativeMayFollow)(?<relativeUri>.*|)))");
Attempting to generate a string that matches this throws the following exception:
	  Regex parse error at index 87: Backref must begin with ' or <.
 
Naturally, index 87 is the end of the above red text in my regular expression.
Now, this is a legal .NET RegEx named-group conditional that states "if the group named 'relativeMayFollow' was matched, then try to match .*, else match nothing.
Any idea on how I can still express the above in a form that TestApi will accept?
Thanks!
Matt
Sep 14, 2011 at 1:13 AM

Matt,

Did you find a work-around?

Sep 14, 2011 at 1:29 AM
Nope. :-)

Sent from my Windows Phone

From: ivom
Sent: 9/13/2011 5:13 PM
To: leclairm@hotmail.com
Subject: Re: GenerateRandomString(RegEx) doesn't parse conditional backrefs? [TestApi:258286]

From: ivom

Matt,

Did you find a work-around?

Sep 14, 2011 at 7:17 PM

Sorry, Matt. We don't currently support regular expression yet. It was planned but never had resource to implement.

Regards,

Dennis