Need help about Regular Expression Syntax
I tried to take only this part(after the "j&q") from link
(http://www.google.com/aclk?sa=lai=CEvAD5thCTfHPCIq5gwe2lOWKD6n_uOIB4bzDkxm8uIhRCAAQASDrxZ0GKANQgI6s开发者_如何学JAVA1ANgybblirSk2A-gAYem9NwDyAEBqQLN5n97JxulPqoEGk_QITE_eyPbZTKIyNFl8dQhptl05oxQ2fHjgAWQTg&sig=AGiWqtwLGY6f1Gnci0e0ojoRsLBxr9joLg&adurl=http://www.mediterraholidays.com/egypt/cairo-and-nile-cruise&rct=j&q=egpyt%20package%20trips
).
I used ^.*q=.*$
but with this. I need only after the j&q part if it has.
Why don't you use System.Uri
class for this:
Uri url = new Uri("http://www.google.com/aclk?sa=lai=CEvAD5thCTfHPCIq5gwe2lOWKD6n_uOIB4bzDkxm8uIhRCAAQASDrxZ0GKANQgI6s1ANgybblirSk2A-gAYem9NwDyAEBqQLN5n97JxulPqoEGk_QITE_eyPbZTKIyNFl8dQhptl05oxQ2fHjgAWQTg&sig=AGiWqtwLGY6f1Gnci0e0ojoRsLBxr9joLg&adurl=http://www.mediterraholidays.com/egypt/cairo-and-nile-cruise&rct=j&q=egpyt%20package%20trips");
var queryString = HttpUtility.ParseQueryString(url.Query);
var q = queryString["q"];
The q
variable holds the value: egpyt package trips
&q=(?<data>[^&]*)
The answer needs to be at least 30 chars, so I add some joke:
“Knock, knock.”
“Who’s there?”
very long pause….
“Java.”
精彩评论