asp.net - How to modify split function to split string -
please me split string "," having "desc,a" single item in result.
string s="\"desc,a\",true,true,false,true,0,1,red,1,1,"
thanks in advance.
you can use regular expression match items , without quotation marks:
string[] items = regex.matches(s, @"""[^""]*""|[^,]+") .cast<match>() .select(x => x.value) .toarray();
explanation:
""[^""]*"" - matches item quotation marks (quot, 0 or more non-quot character, quot) | - or operator [^,]+ - matches item without quotation marks (one or more characters other comma)
Comments
Post a Comment