I have the following regular expression that is capturing two fields.
Notice the {0} near the middle of the expression. I want to replace {0}
with a decimal number using String.Format(). Unfortunately, String.Format()
is getting confused about other {}'s that occur in the regular expression.
I tried escaping the curly braces but C# complained that the resultant
string was an invalid escape sequence.
I could bust up the string below into multiple strings and then do multiple
StringBuilder Append calls to build it up but that seems a bit ugly to me.
Is there a way to pass a regular expression with curly-braces such that
Format() will do its thing properly (i.e. won't get confused about
curly-braces that are really part of the regular expression and should not
be touched)?
(?<DocID>\d{14})\|(?:[\w\s]+\|){0}(?<LineNum>\d+)\|.*
J. Keith Wedinger
Senior Software Developer
Sterling Commerce
===================================
This list is hosted by DevelopMentor� http://www.develop.com
You may be interested in Guerrilla .NET, 24 March 2003, in London and Boston
http://www.develop.com/courses/gdotnet
View archives and manage your subscription(s) at http://discuss.develop.com