I’m trying to pull out sub-string from a string using java.Util.Scan
The sub-string is between “<TD class=MoreB align=center>” and “</TD>” in the original string
This is the code:
public static String pullStringOut(String str)
{
String stringer = null;
Scanner scanner = new Scanner(str);
scanner.findInLine("<TD class=MoreB align=center>");
while (scanner.hasNext() && scanner.next() != "</TD>")
{
stringer+= " " + (scanner.next());
}
return stringer;
}
but it’s not working well.
From the original string:
“<TD class=MoreB align=center>TextTextTextText</TD></TR></TABLE> }“
I get the following result:
“
TextTextTextText</TD></TR></TABLE> }“
Instead of the expected
“TextTextTextText”
You can use a Regex Expresssion.
Something like :
(not tested)