This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 18532
    
  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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Splitting string around "." ?
 
Similar Threads
javascript inside java
Generic Classes question
main method
Spring model attribute silently url-encoded between the controller and the view
showing session id in form dynamically