• Post Reply Bookmark Topic Watch Topic
  • New Topic

Splitting string around "." ?  RSS feed

 
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
Sheriff
Posts: 23295
125
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
Boost this thread!