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
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: 3742
    
  16
"|" 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: 3742
    
  16
[
\
^
$
.
|
?
*
+
(
)
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
 
Don't get me started about those stupid light bulbs.
 
subject: Split function of String class