2

I apologize if it sounds dumb to you, but I need to find __( 'anyTextHere', 'foo' ) and replace all of the instances with 'anyTextHere'.

Basically, I just want to retain 'anyTextHere', then delete the rest.

Sample code:

    __( 'beach', 'foo' )
    __( 'summer', 'foo' )     

then find:

    __( 'anyTextHere', 'foo' )

and when replaced with regular expressions, the result should be:

    'beach'
    'summer'

Thank you very much for your help!

2 Answers 2

2

Search for

 __\( '([^']*)', 'foo' \)

and replace with $1

To be more general:

__\( '([^']*)', '[^']*' \)

and replace also with $1

Sign up to request clarification or add additional context in comments.

2 Comments

@cblab I tested it in v6.1.2 works fine. Probably they changed it when they introduced PCRE regex in v6.0
@stema ah ok, my mistake, so. Good news, BTW.
2

You can replace

__\( '([']+), [^)]+)

by '\1'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.