Regular Expression

  • Thread starter Thread starter Guest
  • Start date Start date
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...
 
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
 
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
 
Back
Top