• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Token

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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".
 
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
incandescent light gives off an efficient form of heat. You must be THIS smart to ride this ride. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic