On Thu, Dec 11, 2003 at 12:48:54PM -0500, Socheavy D. Heng wrote:
> I was having some problems with the regular expression in the code down
> below. Can anybody tell me why the replacement doesn't work. I've used
> various modifiers, but nothing really helped.

Because you're trying to match a string which contains meta-characters
against itself.  Slashes, in this case.

"("  =~ /\(/;   # succeeds
"\(" =~ /\(/;   # fails

You want to escape the metacharacters only in the regex string, not the
target string.

One way to do that is:

$hash{string} =~ /\Q$hash{$string}/


Ronald
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to