Remove part of one field and append to another field

$regex() is a scripting function that can only be used in Format strings. In the action of the type "Replace with regular expression" you have to enter just the patterns that in the end make up the regular expression.
And if in doubt, check the documentation: