2
私はこの質問と同じ作業をgroovyとしたいと思います。Groovy null regex
REGEX: How to split string with space and double quote
def sourceString = "18 17 16 \"Arc 10 12 11 13\" \"Segment 10 23 33 32 12\" 23 76 21"
def myMatches = sourceString.findAll(/("[^"]+")|\S+/) { match, item -> item }
println myMatches
これは結果match
の代わりitem
ほぼ期待される結果を与えるが、引用符が残っを返す
[null, null, null, "Arc 10 12 11 13", "Segment 10 23 33 32 12", null, null, null]
あなたは望ましい結果plsは – injecteer
なぜを提供することができますテキストを解析し、CSVパーサーなどの文字列区切り文字を認識する何かを活用しますか? –
私は@tim_yatesの提案に行くだろう:ホイールを再発明しないでください。 – m0skit0