http://qs321.pair.com?node_id=1102578


in reply to Regular Expression to Extract Anything from Colon Delimited String

The sample data you provide seems to fall into 3 different structures. It makes sense to me to first try to identify which structure a given line is, then parse the specific structure (by splitting into the correct slice of a hash, for example.)

If the sample data here is unrepresentative, another approach would be to separately define what each field should look like, then build full regexp's out of the pieces. For that approach look at Regexp::Assemble or dig into the sources for Regexp::Common.