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

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] =~ /^([^|])+)\|(.*)$/) {

Replies are listed 'Best First'.
Re^5: Getting regular expression right
by Anonymous Monk on Feb 15, 2005 at 13:08 UTC
    I guess that should be:
    if ($_[0] =~ /^([^:]+):([^|]+)(?:\|(.*))?$/ || $_[0] =~ /^([^|])+\|(.*)$/) {