I'd do something like this: https://play.golang.org/p/w4b4z0tVQ8
but it really depends on the details of the encoding and how
robust you want to be with malformed records.

For example, should "[foo[bar]baz]" be treated as
["foo[bar]baz"], ["foo[bar"], ["foo[bar", "baz"] or
as an error ?

On 21 July 2016 at 01:41, rogerjd <rdema...@gmail.com> wrote:
> This handles empty fields [], by adding them to a list of fields or ignoring
> them (it's up to you).
> I would think a case such as ]]]], is an error. That could be handled by
> state machine, ie: Close delim found, with no Open delim,
> That would be easy enough to code.
>
> https://play.golang.org/p/TVsp7UEYc7
>
> Thanks,
> Roger
>
>
>
> On Thursday, July 7, 2016 at 5:28:06 AM UTC-4, Ignazio Di Napoli wrote:
>>
>> On Thursday, July 7, 2016 at 12:05:27 AM UTC+2, Justin Israel wrote:
>>>>
>>>> https://play.golang.org/p/fOFT2voh6l
>>>
>>>
>>> That's pretty sweet.
>>
>>
>> Pretty sweet indeed, but it's worth saying that if the string is [field
>> 1][field 2][][field 4] the result is ["field 1", "field 2", "field4"],
>> ignoring the empty [].
>> Also, "[field 1]]][field 2[field 4]][[" gives the same result. Maybe it's
>> what's intended, maybe not.
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to