Wednesday, July 8, 2009

Nested quantifiers in regex

1st time i'm facing this error...

there's few reason why this happen.

base on article at perlmonks,

if u use regex like this

/^[RE:\s*|FW:\s*]*$match_string\i*$/

and ur $match_string containing '???' it will return error like this.

to solve this, add Q...E at ur regex..

/^(?:RE:\s*|FW:\s*)*\Q$match_string\E$/

this will ignore other special chars that used by regex in ur string.

but, at my error.. i'm mistakenly put extra syntax when trimming my url..

my $urls =~ trimURL();

that produce this error..

so i just remove the '~' at it work fine now... hehehe.. silly mistake.. again

No comments: