0

I have a string like this

String s = "<a title="1.jpg" href="http://example.org/dynamictitle/0001.jpg" othercodeothercode> othercodeothercode <a title="2.jpg" href="http://example.org/dynamictitle/0002.jpg" othercodeothercode> ... ... ...";

with dynamictitle a string that change everytime i change the URL

and I want to split this string to have the single URL like

http://example.org/dinamictitle/0001.jpg
http://example.org/dinamictitle/0002.jpg
...

I tried with contains but I can't think how can I solve the problem of dynamictitle

Thanks a lot

Orla098
  • 1
  • 1
  • Hey! This is a perfect moment to learn [regular expressions](https://www.regular-expressions.info/tutorial.html). – akuzminykh Mar 20 '20 at 17:53
  • @akuzminykh Nope, regex isn't best tool to parse HTML ([link1](https://stackoverflow.com/q/701166), [link2](https://stackoverflow.com/q/590747) and ofc [mandatory answer](https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454)). To parse HTML we need proper *HTML parser* like `jsoup`. Examples: https://jsoup.org/cookbook/extracting-data/attributes-text-html, https://jsoup.org/cookbook/extracting-data/example-list-links – Pshemo Mar 20 '20 at 18:01
  • Regex can be used *after* parsing, when we already found links to filter those which we want from those which we don't want. – Pshemo Mar 20 '20 at 18:03

0 Answers0