It's not a secret anymore!*
The moose likes Beginning Java and the fly likes Using split method with String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Using split method with String " Watch "Using split method with String " New topic
Author

Using split method with String

Moniphal Say
Ranch Hand

Joined: Aug 11, 2004
Posts: 48
Dear all,

How to split a string by a delimiter "." cos normally with the regular expression , "." mean any character. So if I want to split string into part which separted by a "."

For example : with a string "hello.java" , I want to split into , "hello" and "java"


run >> java Test toto.java
The result is --> 0

The string havent split !!

Regards,
moni


<b>The more we learn, the more we know !</b>
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You escape regex special character with '\'. Of course, that character is also an escape character in Java, so you will probably have to escape it twice. Try:


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Moniphal Say
Ranch Hand

Joined: Aug 11, 2004
Posts: 48
Ok, it works with "\\." ,thanks

regards,
moni
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using split method with String
 
Similar Threads
replace String input with parenthesis
converting string array to string
Split String by $
split()
String input with parenthesis