我想用空格分割一个字符,但将空格保留在引号内(以及引号本身)。问题是,引号可以嵌套,而且我需要对单引号和双引号都这样做。所以,从this "'"is a possible option"'" and ""so is this"" and '''this one too''' and even ""mismatched quotes"我想得到的行[this, "'"is a possible option"'", and, ""so is this"", and, '''this one too''', and, even, ""mismatched quotes"]。
这个问题已经被问过了,但不是我要问的确切问题。这里有几个解决方案:一个使用匹配器(在这种情况下"""x"""将被拆分为[""", x"""],所以这不是我需要的)和 Apache Commons (它可以使用"""x"""但不能使用""x"",因为它需要前两个双引号并留下最后两个与x)。也有人建议手动编写一个函数,但这是最后的手段。
慕桂英546537
森林海
随时随地看视频慕课网APP
相关分类