Naresh Naresh - 2 months ago 8
C# Question

Regular expression to extract characters in between other characters

I have a string which is

//{characters}\n
.

And I need a regular expression to extract the character in between
//
and
\n
.

Answer

Using RegEx:

Regex g;
Match m;
g = new Regex("//(.*)\n");  // if you have just alphabet characters replace .* with \w*
m = g.Match(input);
if (m.Success == true)
    output = m.Groups[1].Value;
Comments