• Post Reply Bookmark Topic Watch Topic
  • New Topic

Tokenizing string in Java  RSS feed

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am trying to tokenize a string based on either "<" or ">".
E.g.
If I have a string
"<ATTR>Age <VALUE>100"

The o/p should be
ATTR, Age, VALUE, 100

This is something similar to XML parser I am tryin to do.
I have this piece of code
strToken = new StringTokenizer(str,??);

What Regular expression I should put in place of "??" to get the above o/p

Thanks in advance for any help.

Kashyap
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not good at regex. But what about:

 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another option using the java.util.regex package
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!