wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Splitting string around Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Splitting string around "." ?" Watch "Splitting string around "." ?" New topic
Author

Splitting string around "." ?

Johann Dobbins
Ranch Hand

Joined: Oct 16, 2008
Posts: 62
for whatever reason, i can not split a string around a "." regex. the code:


outputs: 0.


any thoughts?

thanks
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18495
    
  40

for whatever reason, i can not split a string around a "." regex.


The key word in that sentence is "regex". The delimiter specfied to split with is a regex -- and a dot has special meaning in a regex. If you want to split with a dot, you'll need to escape it ... like so.... "\\."

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Johann Dobbins
Ranch Hand

Joined: Oct 16, 2008
Posts: 62
makes sense, thank you

Henry Wong wrote:
for whatever reason, i can not split a string around a "." regex.


The key word in that sentence is "regex". The delimiter specfied to split with is a regex -- and a dot has special meaning in a regex. If you want to split with a dot, you'll need to escape it ... like so.... "\\."

Henry
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Splitting string around "." ?
 
Similar Threads
Generic Classes question
main method
Spring model attribute silently url-encoded between the controller and the view
javascript inside java
showing session id in form dynamically