简体   繁体   中英

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!

You can replace

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

by '\\1'

Search for

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

and replace with $1

To be more general:

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

and replace also with $1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM