Split on comma, but not on quote-enclosed comma

  • Thread starter Thread starter zdrakec
  • Start date Start date
Z

zdrakec

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
 
Got it:

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

Thanks,
zdrakec
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top