in reply to regexp problem, square paranthesis

Hi alex452,

First of all, please wrap your code in <code> ... </code> tags, so that it's easier to read.

Secondly, I think what you're looking for is to "escape" the brackets [ ... ] within your regular expression.  So perhaps you want something like the following ...?

my $tempreg = $p->get_token()->raw; if ($tempreg =~ /\[192\.168\.242\.2\]/) { print "finally a match\n"; }

You can read more about regular expressions in perlrequick, perlretut, or perlre, where you'll see that the bracket characters [ ... ] are "metacharacters" with special meaning (specifically, they delimit "character classes"), so you have to put backslashes in front of any to search for them like other, non-special characters.  The same thing is also true of periods ".", which when unescaped, match any character except newline, and must therefore also be escaped with "\".


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Replies are listed 'Best First'.