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

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -