Created
March 22, 2015 20:55
-
-
Save Dnomyar/80c591d369a43a422a2d to your computer and use it in GitHub Desktop.
Regex : select all spaces not between quotes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Select all spaces not between quotes | |
Useful for command line parsing | |
""" +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)""" | |
Scala example : | |
scala> val input = "hello world \"john doe\"" | |
input: String = hello world "john doe" | |
scala> input split """ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)""" | |
res0: Array[String] = Array(hello, world, "john doe") | |
TODO : Remove quotes in the regex ("john doe" -> john doe) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment