0

I made a mistake writing a template page in Wordpress and so I put regular strings everywhere instead of Gettext calls. Now I should replace all strings in these specific constructs with Gettext calls.

Example:

displayDataRow($$fuelTypePacksName,'model-tech-wheels','Wheels');
displayDataRow($$fuelTypePacksName,'model-tech-curb-weight',__( 'Wheels', 'agr' ));

I haven't learned regex yet, sorry :(

  • What should be replaced??? What is your expected result? – nhahtdh Oct 17 '14 at 10:29
  • Sorry. I'll try to be more clear. The first row in my example is the line of code without a Gettext call, the second one has a Gettext call in it. So the `'Wheels'` part should be replaced with `__( 'Wheels', 'agr' )`. I need the regex because I don't have only the string 'Wheels' but also other strings in similar constructions (passed as displayDataRow() arguments). – user1889705 Oct 18 '14 at 18:41

1 Answers1

0

It is not clear what you want to replace, but the pattern for finding the strings is

'[^']*'

So, if for example you want to replace "hello world" with GetText("hello world") you have to do

 find: ('[^']*')
  replace: GetText(\1)

Essentially, the parantheses added around the pattern mean "keep what you find", and \1 means "replace with the first thing you found.

blue_note
  • 27,712
  • 9
  • 72
  • 90