Question

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>
Was it helpful?

Solution

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)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top