DZ-Jay wrote:

> 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.

Once or more than once ?

> 5. The delimiter can exist within the quoted substrings.

One or more ?  More than one can complicate.

> 6. Non-significant whitespace (surrounding the delimiter) should be 
> removed, i.e. each field should end up "trimmed" after splitting.

Change my split to /\s*[,;]\s*/

> 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!;

Are the <>'s literal or do they indicate a generic address and what
characters can exist in the name and address besides \w chars ?

Making a single RE to handle this would take to much effort when you
have a simpler solution and since it's time consuming, I'll pass for
now (plus I'm no expert at REs - I'm self taught).

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

Reply via email to