使用引号分隔Java字符串

编程入门 行业动态 更新时间:2024-10-27 12:38:02
本文介绍了使用引号分隔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字符串

本文发布于:2023-10-26 22:10:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1531491.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:引号   字符串   Java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!