On Dec 11, 2005, at 09:06, $Bill Luebkert wrote:

DZ-Jay wrote:

Pretty ingenious, albeit a bit of cheating, uh? :)
but if all else fails, I'll probably go with that, thanks!

I still wonder if there is a single regexp that could do what I want,
and if so, I'd like to learn about it. I'm just not very familiar with
backtracking and lookaheads...

Probably, but you never specified an exact set of rules so it would
be near impossible to write one that would work for all cases without
knowing all the cases.

But I did specify the rules:
1. Split on a specified delimiter (for the moment I'm aiming for [,;]), but ideally I would like it to be variable. 2. As opposed to CSV where quoted strings encompass the entire field, quoted substrings can exist within the field. 3. The quotes surrounding a substring are part of the field and should not be removed.
4. Escaped quotes (\") can exist within quoted substrings.
5. The delimiter can exist within the quoted substrings.
6. Non-significant whitespace (surrounding the delimiter) should be removed, i.e. each field should end up "trimmed" after splitting.

And this is an example that covers all the rules:

$foo = qq!"LastName, FirstName" <address>, "Name" <address> , <address>; FirstName LastName , address; "First \"nick\" Last" address!;

Which should yield (note: the brackets below are to mark the edges of the strings):
        ["LastName, FirstName" <address>]
        ["Name" <address>]
        [<address>]
        [FirstName LastName]
        [address]
        ["First \"nick\" Last" address]

Thanks for all the help, I surely appreciate it! :)

        dZ.

--
"Bastard Operators don't just win. Anyone can win. Bastard Operators win and totally demoralise. That's real winning."

        -- BOfH

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to