本文介绍了使用引号分隔Java字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
我需要在Java中分割String。分隔符是空格字符。 字符串可以包括成对的引号(内部包含一些文本和空格) - 成对引号内的整个主体应被视为单个标记。 例如:
I need to split the String in Java. The separator is the space character. String may include the paired quotation marks (with some text and spaces inside) - the whole body inside the paired quotation marks should be considered as the single token. Example:
Input: token1 "token 2" token3 Output: array of 3 elements: token1 token 2 token3如何做? 谢谢!
How to do it? Thanks!
推荐答案拆分两次。首先是引号,然后是空格。
Split twice. First on quotes, then on spaces.
更多推荐
使用引号分隔Java字符串
发布评论