使用正则表达式的vqmod通配符搜索 [英] vqmod wildcard search using regex
本文介绍了使用正则表达式的vqmod通配符搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
作为一个示例,我试图替换所有的$this->load->model(*);
,*表示通配符搜索/替换.在正则表达式中执行此操作的正确方法是什么?
As an example here I am trying to replace all $this->load->model(*);
, the * represents a wildcard search/replace. What is the correct way to do this in a regex?
<operation>
<search regex="true" position="replace"><![CDATA[ $this->load->model(.*); ]]></search>
<add><![CDATA[ $this->load->model('catalog/information'); ]]></add>
</operation>
推荐答案
所需的转义应该很小.您只需要像这样转义$
和括号
The escaping required should be pretty minimal. You only need to escape the $
and the parentheses like so
<search regex="true" position="replace"><![CDATA[~\$this->load->model\(.*?\);~]]></search>
同样,您已经正确地回答了这个问题,您需要添加一个定界符(我发现~
出现在字符串中的可能性远小于/
,因此使用了它)
Also as you've rightly done in your answer to this, you need to add a delimiter (I find ~
is far less likely to be in a string than /
hence using that instead)
这篇关于使用正则表达式的vqmod通配符搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文