in reply to Help with regex for complicated key=value string

Points 1.-3. alone can be simply done with some negative look-behind,

Point 2 can't be done using just a look-behind if you can escape slashes as well as commas.

key1=\\\\\\value\\\\\\,key2=///value///

Replies are listed 'Best First'.
Re^2: Help with regex for complicated key=value string
by JavaFan (Canon) on Oct 29, 2008 at 18:52 UTC
    Point 2 can be done with:
    split /(?:^|[^\\])(?:\\\\)*\K,/ # 5.10 required
    But that's just point 2, it doesn't consider commas inside quotes.
      That would be:
      split /(?:$key_pat=)?$val_pat\K,/

      Using split means everything has to be parsed twice. Once to find the commas on which to split and once to find the composing terms.

      Update: Simplified pattern slightly.

      A reply falls below the community's threshold of quality. You may see it by logging in.