I'm not familiar with phpstorm, but the reason you're getting a malformed replacement string error is probably because you're using $1 to reference the first grouping, when there is no first grouping.
Try using this:
echo \$(.*?);
And replace again with this, like you originally did:
echo stripslashes($1);
Basically all I did was group .* so that $1 would be able to reference it, and added a lazy modifier to the star just to avoid any weird stuff happening later on in the parse. I also removed the \, since ; itself doesn't stand for anything in regex, escaping it is unnecessary.
Here's a test to verify that it works: http://fiddle.re/9e47