aspose file tools*
The moose likes Java in General and the fly likes Split function of String class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Split function of String class" Watch "Split function of String class" New topic
Author

Split function of String class

Sim Kim
Ranch Hand

Joined: Aug 06, 2004
Posts: 268
Hi All,

I am trying to use Split function of String class . But it does not seem to work fine .

Example :

"Hello@Hi@Bye".split("@") : Works fine

but :

"Hello|Hi|Bye".split("|") : Does not works as intended .

Can somebody tell me why delimiter character "|" cannot be used ?
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3169
    
  10
"|" is a special character in regular expressions. You need to escape it


Joanne
Sim Kim
Ranch Hand

Joined: Aug 06, 2004
Posts: 268
Which all are the special characters . I guess "|" and "*" . Are there any more ?
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3169
    
  10
[
\
^
$
.
|
?
*
+
(
)
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
See the doc for Pattern. You can make some pretty fancy delimiters!


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Split function of String class
 
Similar Threads
simple question
Doubt about IO package
Garbage
How to share the same events for multiple components?
getting last piece of string