• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using split method with String

 
Moniphal Say
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Moniphal Say
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, it works with "\\." ,thanks

regards,
moni
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic