Regular Expression

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...
 
T

Tyler

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top