gpt4 book ai didi

java - StringUtils 拆分包含字符串的逗号问题

转载 作者:太空宇宙 更新时间:2023-11-04 12:16:12 24 4
gpt4 key购买 nike

我想解析这个字符串内容。

   requiredContent='Tigers that breed with lions give birth to hybrids known as "tigons" and "ligers."// In 19th-century Sweden, 380 kids were strangled by their mothers or nurses every year, according to the Swedish Statistical Bureau.'

我用它分割了

 String[] factsArray = StringUtils.split(requiredContent, "//");

我得到了结果

  [Tigers that breed with lions give birth to hybrids known as "tigons" and "ligers.", In 19th-century Sweden,  380 kids were strangled by their mothers or nurses every year,  according to the Swedish Statistical Bureau.]

生成的factsArray应该有一个长度为2的数组,但它显示的是一个长度为4的数组。它正在解析字符串中包含“,”的字符串。这不应该发生,如何解决这个问题???

最佳答案

这只是数组逗号分隔符和字符串逗号显示上的冲突

验证factsArray.length结果,它是2而不是4

关于java - StringUtils 拆分包含字符串的逗号问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39388104/

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