How to concatenate $1 with number in a regex

Viewed 3623

I would like to insert the number between two patterns:

$s = 'id="" value="div"';
$s =~ s/(id=")(".*)/$1123$2/;

Of course I got the error and " value="div" as a result. The expected result is id="123" value="div".

In the replacement I meant $1, then number 123 and then $2, but not $1123 and then $2. What is the correct replacement in the regex? I would like to do it in one single regex.

Thanks.

2 Answers
Related