5

I trying to regex replace echo $review->helpful; with echo stripslashes($review->helpful); in PHPstorm without any luck.

I tried echo \$.*\; with echo stripslashes($1); but didn't worked I get malformed replacement string.

Any help will be appreciated.

Thanks

1 Answer 1

12

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.