Regular Expression

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Give
string s = "name=""jim"""

I want a regular expression that will take the name value pair of s and return a match on the value
Ex
string pattern = <this is some reqular expression pattern>; // this is what I am trying to fin

Regex re = new Regex(pattern)

Match match = re.Match(s)

match.ToString() will equal jim. Not "jim

What is the reqular expression that I should use? Can someone please help

Thanks...
 
Does the following example meet your requirements?

string s = "name=\"jim\"";
string pattern = "name=\"(?<Value>.*)\"";
Regex re = new Regex(pattern);
Match match = re.Match(s);
if( match.Success )
{
string value = match.Result("${Value}"); // value = "jim"
}

Best regards, Tyler
 
Back
Top