This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Splitting String at "."  RSS feed

 
Mike Himstead
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'd like to seperate a String containing dots (".") with the split method, this method uses regular expressions. The dot is reserved as a place holder for any character, so someString.split(".") won't work. How do I enter the dot as a regular expression?
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Escape it:
 
Mike Himstead
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Duh! Thank you. I misunderstood the instructions in the Java doc.
 
Alan Moore
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mike Himstead:
Duh! Thank you. I misunderstood the instructions in the Java doc.

Unfortunately, that's not hard to do. The javadoc is really just a list of supported features; to learn how to use regexes, you need to look elsewhere. There's a good tutorial here:

http://www.regular-expressions.info/

and then there's The Book:

http://www.amazon.com/exec/obidos/ASIN/0596528124/masteringregu-20
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!