jazzQuery
jazzQuery

Reputation: 23

Notepad++: Find and replace using regular expressions

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!

Upvotes: 2

Views: 229

Answers (2)

stema
stema

Reputation: 92986

Search for

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

and replace with $1

To be more general:

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

and replace also with $1

Upvotes: 2

Joey
Joey

Reputation: 354516

You can replace

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

by '\1'

Upvotes: 2

Related Questions