Replace characters in notepad ++. BUT exclude characters inside single quotes (2nd)

replace characters in notepad ++ BUT exclude characters inside single quotes

Sorry, for all users (especially for Avinash Raj) who have already answered one similar question - I just forgot the second type of line. (And (this is a sad thing) - I cannot configure the solution from the first familiar question to the second type of string ...)

I have two different lines of this kind:

SELECT column_name FROM table_name WHERE column_name IN ('A' , 'st9u' ,'Meyer', ....);
WHERE    a.object_type IN (' 'TABLE'', ''MATEerialIZED VIE3W'   ')

I want to replace all characters in notepad ++ from top to bottom, but exclude single quotes from the replacement characters inside.

condition: There is no continuous structure before / behind / between a part of single quotes!

(This means that I cannot use the keyword "IN" or characters like "," or "(" or ")" or ";" for this regular expression ...!)

Once upon a time, there are two possible structures for single quotes: "Word | Number" or '' Word | Number '' (but, as shown in the 2nd example, with a different number of spaces between each individual quote!).

target string (characters inside single quotes must remain unchanged):

select column_name from table_name where column_name in ('A' , 'st9u' ,'Meyer', ....);
where    a.object_type in (' 'TABLE'', ''MATerialIZED VIE3W'   ')

How can I exclude quotation marks from notation ++ (from replacement)?

+1
source share
1 answer

'... '.... abc '' \K . , . , :

'\s*(?0)?[^']*'\K|(\w+)
  • (?0)?
  • \s shorthand [ \t\r\n\f]
  • \w - [A-Za-z0-9_]

\L\1 , , \U\1 .
NP ++ 6.7.9.2 . . regex101 .

enter image description here

+1

All Articles