gpt4 book ai didi

java - 如何在java中的引号之间获取数据?

转载 作者:IT老高 更新时间:2023-10-28 20:31:10 26 4
gpt4 key购买 nike

我有这行文本,引号的数量可能会改变:

Here just one "comillas"
But I also could have more "mas" values in "comillas" and that "is" the "trick"
I was thinking in a method that return "a" list of "words" that "are" between "comillas"

如何获取引号之间的数据?

结果应该是:

comillas
mas, comillas, 把戏
a, words, are, comillas

最佳答案

您可以使用正则表达式来找出此类信息。

Pattern p = Pattern.compile("\"([^\"]*)\"");
Matcher m = p.matcher(line);
while (m.find()) {
System.out.println(m.group(1));
}

此示例假定正在解析的行的语言不支持字符串文字中双引号的转义序列,不包含跨越多个“行”的字符串,或不支持单引号等字符串的其他分隔符。

关于java - 如何在java中的引号之间获取数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1473155/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com