简体   繁体   中英

Find URLs in String with Jsoup

I have String value that is txt (not html) that contains urls:

Blabla http://www.example.com/foo1/ blabla http://www.example.com/foo2/ blabla...

I need to grab all these urls from the string using Jsoup.

Is it possible?

No, Jsoup won't do this for you. Jsoup parses HTML tags, not arbitrary strings.

If you had an HTML document containing a bunch of link tags ( <a href="http://example.com/page.html>link text</a> ), you could use Jsoup to parse the tags and extract the href attribute.

If you just have a string with some links, you probably want to use regular expressions , as suggested in a comment by PeterMmm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM