my question is how would i be able to go through a string and take out only the links and erase all the rest? I thought about using some type of delimiter, but wouldn’t know how to go about using it in Java. an example of what i am trying to do:
this is my String:
String myString = "The file is http: // www. .com/hello.txt and the second file is "
+ "http: // www. .com/hello2.dat";
I would want the output to be:
"http: // www. .com/hello.txt http: // www. .com/hello2.dat"
or each could be added to an array, separately. I just want some ideas, id like to write the code myself but am having trouble on how to do it. Any help would be awesome.
Regular Expressions, or Regex, is built for this kind of work.
It is like another mini-language to learn. The best book out there some would say is Mastering Regular Expressions
The Javadoc for Pattern and Matcher can only serve as a reference. It completely ignores the subtleties involved in regex.