Alex Rivera | Logout

Regex.Replace: How to use $groups followed by numbers

Asked 2009-05-01T12:12:41.927
32

With Regex::Replace we can use $1, $2, ... to match corresponding groups. But how can I use $1 followed by number. E.g. to replace 6 with 678?

 Regex::Replace(text, "(6)", '$178');
Edit
Report

1 Answer

51

You need to use the alternate syntax:

Regex::Replace(text, "(6)", "${1}78");
answered 2009-05-01T12:17:44.020

Your Answer