java.util.Regexp.Matcher issue with double quote

N

nicolaspujol

Hi,

I have the following regexp code which seems to be having an issue
handling a double quote.

String strMatch_pattern="(.*action\\=\")(.*)\"";
Pattern pattern=Pattern.compile(strMatch_pattern);
Matcher matcher=pattern.matcher(new StringBuffer("Hello
action=\"nicolas\" is here post=\"post\""));
while(matcher.find())
{
String strURL=matcher.group(2);
System.out.println(strURL);
}
This prints

nicolas" is here post="post

but should really print
nicolas

Any ideas as to what i could be doing wrong?
 
N

nicolaspujol

Ok it is my bad. I got it. The proper expression is:

String strMatch_pattern="(.*action\\=\")([^(\")]*)\"";
 

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

Similar Threads

Regexp expression issue 1
Question on regular expression. 6
Hostname verifier 0
Java Regex Problem 7
Hostname verifier in JAVA 0
complex regex 1
complex regex 1
Certificate validation 1

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top