I am currently have a program that can find all the regexs that are in a string, however for a different part I want the parts that match the regex and the parts that don't.
So if I had <h1> hello world </h1>
I would want to be able to split it up into [<h1>
, hello world
, </h1>
].
Does anyone have any ideas on how to they would go about this?
Here is my code that splits up the string to find the regex part
ArrayList<String> foundTags = new ArrayList<String>();
Pattern p = Pattern.compile("<(.*?)>");
Matcher m = p.matcher(HTMLLine);
while(m.find()){
foundTags.add(m.group(0));
}
hello world
" = [ h1, hello world, /h1]. The logic of how to tell if its html is already written and tested in another part of the code – Tall Paul Mar 26 '13 at 02:13<>`. I'm just saying text processing on Html isn't that reliable. Continue at your own risk...
– nattyddubbs Mar 26 '13 at 02:18