Amin Abdolrezapoor
Amin Abdolrezapoor

Reputation: 1847

Simple Regex find and replace in a php file using notepad++

I've got a really large array that i need to replace some stuffs in it ( using notepad++ regular expression search and replace ) but i don't the right Regex for it , and everything i tried failed.

Example :

'label' => 'Some text',

Must be replaced with :

'label' => __('Some text', 'mytextdomain'),

Upvotes: 0

Views: 98

Answers (1)

Jerry Jeremiah
Jerry Jeremiah

Reputation: 9618

Make sure that the Regular Expression radio button is clicked on the Search Mode panel of the Replace dialog. Then

Find what: ('[^']*') => ('[^']*') Replace with: \1 => __\(\2, 'mytextdomain'\)

The main thing is that if you want parenthesis in your result they need to be escaped because parenthesis are special just like ^ & . + and *

Upvotes: 2

Related Questions