简体   繁体   English

Notepad ++:使用正则表达式查找和替换

[英]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' . 如果您听起来__( 'anyTextHere', 'foo' )我深表歉意,但是我需要找到__( 'anyTextHere', 'foo' )并将所有实例替换为'anyTextHere'

Basically, I just want to retain 'anyTextHere' , then delete the rest. 基本上,我只想保留'anyTextHere' ,然后删除其余部分。

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' '\\1'

Search for 搜索

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

and replace with $1 并替换为$1

To be more general: 更笼统地说:

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

and replace also with $1 并替换为$1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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