[英]phpstorm regex search and replace
I trying to regex replace echo $review->helpful;
我试图正则表达式取代
echo $review->helpful;
with echo stripslashes($review->helpful);
with
echo stripslashes($review->helpful);
in PHPstorm without any luck. 在PHPstorm没有任何运气。
I tried echo \\$.*\\;
我试过
echo \\$.*\\;
with echo stripslashes($1);
带有
echo stripslashes($1);
but didn't worked I get malformed replacement string. 但没有奏效我得到了错误的替换字符串。
Any help will be appreciated. 任何帮助将不胜感激。
Thanks 谢谢
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. 我不熟悉
phpstorm
,但是你得到malformed replacement string
错误的malformed replacement string
错误的原因可能是因为当没有第一个分组时你使用$1
来引用第一个分组。
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. 基本上我所做的就是分组
.*
这样$1
就可以引用它,并为星星添加了一个懒惰的修饰符,以避免后来在解析中发生任何奇怪的事情。 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 这是验证它是否有效的测试: http : //fiddle.re/9e47
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.