本文介绍了字符串分割问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个解析器,当涉及string.split()时,我遇到了一个问题.

I''m building a parser and I have a problem when it comes to string.split().

Dim currentstring As String
currentstring = "'They are running, John','the dogs'"
currentstring.split(",")



当我分割字符串时,也会在撇号之间分割逗号.有什么方法可以解决这个问题,所以它只会将那些撇号分开吗?



When I split the string it will split the commas in between the apostrophes too. Is there any way to get around that so it will only split the ones out side the apostrophes?

推荐答案



string currentstring = "'They are running, John','the dogs'";
string[] result = Regex.Split(currentstring, ",(?=(?:[^']*'[^']*')*[^']*


这篇关于字符串分割问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 12:56