2

I am having following code but unable to understand as to why no match is returned? What change do I need to make?

string temp = "qqqqqqqq<ahref=\"city.php?city=qqqqqqq";
Regex r = new Regex("<ahref=\"city.php?city=");
Match m = r.Match(temp);

The variable m doesn't return a match.

Thanks

Varun

0

1 Answer 1

6

You did not escape the dot . and the question mark ? meta-characters.

Regex r = new Regex("<ahref=\"city\\.php\\?city=");
Sign up to request clarification or add additional context in comments.

1 Comment

@VVV I just fixed it - you need to double the slashes.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.