• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to split string using . operator

 
santhosh.R gowda
Ranch Hand
Posts: 296
  • 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
Posts: 48374
56
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Here it is not spliting the string...?
 
Rob Spoor
Sheriff
Pie
Posts: 20492
54
Chrome Eclipse IDE Java Windows
  • 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
  • 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
  • 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
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot i got it..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic