Let's say I have something like:
Sample 1: Your number is <foo>12345</foo> and your code is <foo>29939</foo>.
Sample 2: Your number is <foo attr="x">12345</foo> and your code is <foo>29939</foo>.
I would like to break this String into an array of string.
Something like the following for Sample 1:
array[0] = Your number is
array[1] = 12345
array[2] = and your code is
array[3] = 29939
Sample 2:
array[0] = Your number is
array[1] = x|12345 (adding attr value to it)
array[2] = and your code is
array[3] = 29939
I am looking for <foo>
with or without attribute in the String and need to break the String accordingly.
I found an easy way to replace something under with some value.
Example: matcher.replaceAll("bar")
which resulted in something like:
Your number is bar and your code is bar
What I would like to see is to the break the string into an array or list whenever I see the tag <foo>
in the string value.