A
A
amorphine2016-08-18 11:28:35
Java
amorphine, 2016-08-18 11:28:35

How to select direct link from google url using regular expressions?

Required from links like
https://www.google.com/url?rct=j&sa=t&url=http://t...
Get links like:
tower43.ru/b0013232
Using the service , I wrote a regular expression

String pattern = "(\\S)(https?:[\\S]*)(&ct=ga&cd=)";
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(url);

When I try to extract the second group, I get an IllegalStateException
On the site, groups are recognized normally (although \1 doesn't work for some reason)
3236c8f8bca44e86b4abb41b5ecb1c0a.png
Perhaps I have the wrong approach from the beginning? Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Osher, 2016-08-18
@amorphine

Easy weasy.
stackoverflow.com/questions/21545912/url-parsing-i...
stackoverflow.com/questions/13592236/parse-a-uri-s...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question