Adding a literal to a regex match

  • Thread starter Thread starter Lee Kuhn
  • Start date Start date
L

Lee Kuhn

Is there a way to add a literal character to a regex match? For example,
normally applying the regex ..$ to the string "123456" results in a match
"56". I want to be to add a literal character to the beginning of the
resultant match string. In other words, is there a regex that could be
applied to the string "123456" to a get a match string "056"?

Thanks.
 
Lee Kuhn said:
Is there a way to add a literal character to a regex match? ...

Yes:
Match m = Regex.Match(...);
string x = "0" + m.ToString();

I guess you somehow wanted to state this 'inside' the regex search pattern.
As the name says it's a search pattern, so, no, you cannot do this.

Niki
 
Back
Top