简体   繁体   English

Notepad ++查找并替换多个正则表达式

[英]Notepad++ find and replace multiple regex expressions

I found help regarding multiple search and replaces at once, but they usually cover only plain words search and replace. 我发现了有关多次搜索和替换的帮助,但它们通常仅涵盖普通单词的搜索和替换。 ( Multiple word search and replace in notepad++ ) 在记事本++中搜索和替换多个单词

I have data that can have three different styles. 我的数据可以具有三种不同的样式。

(15:

(4:

(:

Infront of each of these is a random number of spaces with I am trying to replace with a single space. 每一个的前面都是随机数的空格,我尝试用一​​个空格替换。 I have the regular expression search for each by individually. 我每个人都有正则表达式搜索。

Find what: *\\(([0-9])([0-9])\\: 查找内容: *\\(([0-9])([0-9])\\:

Replace with: \\(\\1\\2\\: 替换为: \\(\\1\\2\\:

Find what: *\\(([0-9])\\: 查找内容: *\\(([0-9])\\:

Replace with: \\(\\1\\: 替换为: \\(\\1\\:

Find what: *\\(\\: 查找内容: *\\(\\:

Replace with: \\(\\: 替换为: \\(\\:

If I try to combine them into a single find and replace code, I try; 如果我尝试将它们组合为单个查找和替换代码,则尝试;

Find what: ( *\\(([0-9])([0-9])\\:)|( *\\(([0-9])\\:)|( *\\(\\:) 查找内容: ( *\\(([0-9])([0-9])\\:)|( *\\(([0-9])\\:)|( *\\(\\:)

Replace with: (?1 \\(\\1\\2\\:)(?2 \\(\\1\\:)(?3 \\(\\:) 替换为:( (?1 \\(\\1\\2\\:)(?2 \\(\\1\\:)(?3 \\(\\:)

However, this does not complete the three replaces with the desired results that occur when run individually. 但是,这并不能完成三个替换,而单独运行时会出现期望的结果。

What kind of adjustments do I need to make the replace code work? 为了使替换代码生效,我需要进行哪些调整? Cheers 干杯

You can use the following regex. 您可以使用以下正则表达式。

Find:  *(\(\d*:)
Replace:  \1

Live Demo 现场演示

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

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