简体   繁体   中英

Notepad++ regular expression issue with non matching patterns

I'm trying to modify lines that do not contain one pattern but do contain another pattern:

Table: tablename         page.
Table: xxcellname 

Whenever the word "Table" appears at the start of a line and the word "page" does NOT appear on the line, I want to replace "Table: " with white space. so that in the above example

Table: xxcellname

becomes

         cellname

and

Table: tablename         page.

Stays the same

I've tried using:

Replace (^Table :)^((!?.*Page).)*$ with \\2

Try this expression:

(?m)^Table:((?:(?!page).)*)$

and replace with 6 spaces and the first capture group:

      \1

When applied to the input:

Table: tablename         page.
Table: xxcellname 
Table: tablename         page.
Table: xxcellname 
Table: tablename         page.
Table: xxcellname 

it will provide the following output:

Table: tablename         page.
       xxcellname 
Table: tablename         page.
       xxcellname 
Table: tablename         page.
       xxcellname 

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