• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Token

 
Karen Baog
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I want to be able to split a string, for example;

Hello there\\end1 my dear\\end2

into...


Hello there
my dear

Basically, the tokens are \\end1 and \\end2.

I've looked at the StringTokenizer and split, but the delimiter is, even though a string, treats every character in the string a a delimiter. If I use "\\" as the argument, then it will also print the "end1" and "end2".
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried using a regex (regular expression) based search and replace to replace all the "\\endn" instances with a newline character? That would probably be the way to go.

If you are not familiar with regex, there's a great information site, Regular-Expressions.info, that has tutorials, as well as specifics on using Regular Expressions in Java. There is also a Sun Tutorial on Regular Expressions in Java.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic