J
Jason C
I'm doing a replace, like this:
$text = "Yes dear!";
$pattern = "(D|d)ear";
$replace = "$1eer";
$text =~ s/$pattern/$replace/gi;
That's just an example, of course; the real $pattern and $replace come from a database list, and $text comes from form data.
The problem I'm having is that the replace is replacing with a literal "$1eer", instead of setting the $1 to (D|d). Meaning, instead of printing:
Yes deer!
I'm printing:
Yes $1eer!
Any suggestions on how to make $1 in $replace refer to the first group in $pattern?
$text = "Yes dear!";
$pattern = "(D|d)ear";
$replace = "$1eer";
$text =~ s/$pattern/$replace/gi;
That's just an example, of course; the real $pattern and $replace come from a database list, and $text comes from form data.
The problem I'm having is that the replace is replacing with a literal "$1eer", instead of setting the $1 to (D|d). Meaning, instead of printing:
Yes deer!
I'm printing:
Yes $1eer!
Any suggestions on how to make $1 in $replace refer to the first group in $pattern?