in reply to Re^2: Getting regular expression right
in thread Getting regular expression right

I cannot get this example working?

If you say so. Why not? No match? Error? Match when it shouldn't? Wrong content of variables? Explain yourself.

And should @key be %key?

No.

Replies are listed 'Best First'.
Re^4: Getting regular expression right
by mellin (Scribe) on Feb 15, 2005 at 12:25 UTC
    There seems to be error with the regex.

    Error when pasted to my script:
    [mellimik@localhost cgi-bin]$ perl -cw formCreator.pl Scalar found where operator expected at formCreator.pl line 286, near +"?:\|(.*))?$/" (Missing operator before $/?) syntax error at formCreator.pl line 286, near "[^" formCreator.pl had compilation errors.
    It's the character class inside the second last memory parentheses:
    if (/$_[0] =~ /^([^:]+):([^|]+)(?:\|(.*))?$/ || $_[0] =~ /^([^|)+)\|(.*)$/) {
    Should be like this:
    if (/$_[0] =~ /^([^:]+):([^|]+)(?:\|(.*))?$/ || $_[0] =~ /^([^|])+)\|(.*)$/) {
      I guess that should be:
      if ($_[0] =~ /^([^:]+):([^|]+)(?:\|(.*))?$/ || $_[0] =~ /^([^|])+\|(.*)$/) {