Regular Expression

G

Guest

Given
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 find

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

Derek Harmon

Gary Brunton said:
Given
string s = "name=""jim""";
string pattern = <this is some reqular expression pattern>; // this is what I am trying to find
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.

string pattern = "jim";


Derek Harmon
 
M

Michael Sparks

Gary Brunton said:
Given
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 find

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

string s="name=\"jim\"";
string pattern="\"(.*)\"";
Regex re=new Regex(pattern);
string result=re.Match(s).Groups[1].Value;

Mike
 

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