I'm not sure what kind of 'list of websites' you're referring to, but for eg. a comma-separated file of websites you could read the entire file and use the String
split
function to get an array, or you could use a BufferedReader
to read the file line by line and add to an ArrayList
.
From there you can simply loop the array and append to a String
, or if you need to:
do a "block escape", so everything in between the "block" is escaped
You can use a Regular Expression to extract parts of each String
according to a pattern:
String oldString = "I only want this part";
String regExp = "(?i)()(.+?)()";
String newString = oldString.replaceAll(regExp, "$2");
The above expression would remove the xml tags due to the "$2"
which means you're interested in the second group of the expression, where groups are identified by round brackets ( )
.
Using "$1$3"
instead should then give you only the surrounding xml tags.
Another much simpler approach to removing certain "blocks" from a String
is the String
replace
function, where to remove the block you could simply pass in an empty string as the new value.
I hope any of this helps, otherwise you could try to provide a full example with you input "list of websites" and the output you want.