简体   繁体   中英

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])\\:

Replace with: \\(\\1\\2\\:

Find what: *\\(([0-9])\\:

Replace with: \\(\\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])\\:)|( *\\(\\:)

Replace with: (?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

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