Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to extract tag from java by expression.

 
John McDonald
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I would like to use token to extract <B>bold</B> to three simple tokens. Any idea how to define this expression in StringTokenizer, please? Thanks and much appreciate.

John
 
Barry Higgins
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<B> bold </B>

(<*> (*)(</*>

You can then reference each token using the group function in Matcher.
eg.

Mathcher m=Pattern.compile("(<*> (*)(</*> ").matcher(stringForParsing);
for (int i=0; i<=m.groupCount(); i++)
System.out.println(m.group(i));

Hope that helps,
Barry
 
Barry Higgins
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The smiley faces went in there automatically that expression should look like
"(<*>)(*)(</*>)"
I hope it came out OK this time
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic