in reply to Re^2: Help with regex for complicated key=value string
in thread Help with regex for complicated key=value string

$esc is never used in your code, so that means "\\," is not handled yet.

but without doing strict error-checking like yours

It's not really. It only checks for 'key=,...' (key with no value) and 'v"alu"e' (invalid quoting).

Because only alphanumerical keys are allowed anyway (I didn't mentioned that before, sorry) there is no need to look for escaped '=', etc., i.e. everything which doesn't start with /\s*[\w_]+=/ is taken as a single key-less value.

That's the same strategy I used, but I didn't limit to alphanum chars. To do so, change
/\G ( [^=,]+ ) = /xgc && ( $key = $1 );
to
/\G ( [a-zA-Z0-9]+ ) = /xgc && ( $key = $1 );

Replies are listed 'Best First'.
Re^4: Help with regex for complicated key=value string
by mscharrer (Hermit) on Oct 29, 2008 at 19:43 UTC
    $esc is used:
    if ($esc) { $esc = 0; } ... elsif ( $char eq '\\' ) { $esc = 1; }
    and "\\," is handled quite well in my tests.

    Do I miss here something?

      Nevermind. I wrongly thought
      if ($esc) { $esc = 0; } ... elsif ( $char eq '\\' ) { $esc = 1; }
      was identical to
      ... elsif ( $char eq '\\' ) { }