Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Splitting string around "." ?

 
Johann Dobbins
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for whatever reason, i can not split a string around a "." regex. the code:


outputs: 0.


any thoughts?

thanks
 
Henry Wong
author
Marshal
Pie
Posts: 21504
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Johann Dobbins
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic