File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

split ?

 
Ganesan Ramakrishnan
Ranch Hand
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a problem in string.split("|");

for example,



the above code not working properly.

i want to split the above string Ganesan and Ramakrishnan.

any suggestion would be appreciated.

Regards
Ganesan
 
Sagar Rohankar
Ranch Hand
Posts: 2904
1
Java Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The quick answer ll be, no allowed "pipe" | operator, See the docs for valid regex..

This thread discuss the rest ..
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The important point is that the argument to split is a regular expression, and that in regular expressions certain characters have special meaning, e.g. the "|" symbol. If those are to be used with their literal meaning they need to be escaped, which is done by preceding them with a backslash. Try using "\|".
 
Campbell Ritchie
Sheriff
Pie
Posts: 47222
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't try using regular expressions until you have read about them in the Java� Tutorials.
 
Rob Spoor
Sheriff
Pie
Posts: 20368
43
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
The important point is that the argument to split is a regular expression, and that in regular expressions certain characters have special meaning, e.g. the "|" symbol. If those are to be used with their literal meaning they need to be escaped, which is done by preceding them with a backslash. Try using "\|".

Of course you need to escape the backslash as well because it's a Java escape character too so it should be "\\|"
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic