This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to split string using . operator

 
santhosh.R gowda
Ranch Hand
Posts: 296
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to split the string using . operator....but its not spliting when i use split(".") please help me
 
Campbell Ritchie
Sheriff
Pie
Posts: 47274
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would benefit from a trip to the Java™ Tutorials, where you find that . is a meta-character (not in this instance an operator) matching almost anything. You will also find out how you can escape that character with the backslash character, so it does what you want.
 
santhosh.R gowda
Ranch Hand
Posts: 296
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Here it is not spliting the string...?
 
Rob Spoor
Sheriff
Pie
Posts: 20381
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you've read that link Campbell gave you you would have seen that "." is a meta character in regular expressions that means "any character".
 
santhosh.R gowda
Ranch Hand
Posts: 296
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not using regular expression im using only string objects tell me how to split the string using split method
 
Sean Clark
Rancher
Posts: 377
Android Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The split method takes in a regular expression as the argument, you must use one.
 
krishna bala
Ranch Hand
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use below code to split string , which has '.' as delimit

String valore = "aaa.bbb.ccc.dddd" ;
for ( String result : valore.split("\\.") ) {
System.out.println(result);
}
 
santhosh.R gowda
Ranch Hand
Posts: 296
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot i got it..
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic