this won't work, the quote must stay before the delimiter.
okay, what exactly do you want to match? the value of the variable?
would simply be "/$name/"
or a dollar sign, followed by the string 'name'?
should be fine with your approach, or use single quotes to safe one backslash:
'/\$name/'