I have a custom transport format that packages data up in the following format
[a:000,”name”,”field”,”field”,”field”]
I’m trying to split the individual lines out to get the first character after the left bracket and all the CSV values.
a, 000, “name”, “field”, “field” etc…
I cobbled together
[^?,:\[\]]
This splits all the individual characters out not the colon/comma delimited fields.
I understand this won’t accommodate commas within quotes.So it’s clearly rubbish!
Embedded commas isn’t really a huge issue as we’re in control of the data at both ends so I could just escape them.
Thanks for any insight!
Instead of trying to split on multiple characters and ignore some of them, try to match whatever you want to match. Since you didn’t specify the implementation language I am posting this for Perl but you could apply it to any flavor which supports lookbehind and lookaheads.
Explanation:
See it working.