java - Count number of word in string which is having html tags -
consider following string has html tag
"<p>article</p> <p>article</p> <p>article</p> <p> </p>";
now want count number of word contained in above mentioned string
it produce worong output
instead of 3 word count displays 4 word count
it consider <p> </p>
word wrong
please correct following program
string str = "<p>article</p> <p>article</p> <p>article</p> <p> </p>"; org.jsoup.nodes.document dom = jsoup.parse(str); string str2 = dom.text(); system.out.println(str2.split(" ").length);
what changes should made correct output?
thanks in advance.
as benjamin mentioned in comment, after  , should add semicolon ( ). if not add it, cannot parse based on instructions because thought "one element", not want.
Comments
Post a Comment