I am receiving the left and right sides of a regular expression replacement as the arguments to a function. I want my users to be able to use capture buffers, but it doesn't work the way I'm trying to do it.

```
my $string = "This is my string";

$string = regex_replace($string,'is (my) string','$1');

print "$string\n";

sub regex_replace {
    my ( $string,$left,$right ) = @_;

    $string =~ s/$left/$right/gsm;

    return $string;
}

```

Executing this outputs "This $1" instead of the "This my" I am trying to get. Is there any way to accomplish what I am trying to do here?