By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,041 Members | 1,056 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,041 IT Pros & Developers. It's quick & easy.

Split on comma, but not on quote-enclosed comma

P: n/a
i.e. I want to split a string on , unless the , is quoted, thus:

"She is a , very 'fine,girl', and she walks, everyday"

should end up as:

"She is a"
"very 'fine,girl'"
"and she walks"
"everyday"

Help???

Cheers,
zdrakec

Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Got it:

system.Text.RegularExpressions.Regex.Split("She is a , very
'fine,girl', and she walks, everyday",",\s'*,*'*")

Thanks,
zdrakec

Nov 21 '05 #2

P: n/a
Actually, that didn't got it. This got it.

,(?=([^\']*\'[^\']*\')*(?![^\']*\'))

Blessings to the fellow who created that expression, I don't know who
it was...

Cheers,
zdrakec

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.