找到你要的答案

Q:replace characters in notepad++ BUT exclude characters inside single quotation marks

Q:在记事本+ +中替换字符,但在引号内排除字符

I have a string in this kind:

SELECT column_name FROM table_name WHERE column_name IN ('A' , 'stu' ,'Meyer', ....);

I want replace all characters in notepad++ from upper to lower (or vice versa) BUT, exclude from replacement, characters inside single quotation marks.

condition: It exists no solid structure before/behind the single quotation marks part!

(That means - I can not use the keyword "IN" or signs like "," or "(" or ")" or ";" for this regex ...!)

target string (the characters inside single quotation marks have to stay unchangend):

select column_name from table_name where column_name in ('A' , 'stu' ,'Meyer', ....);

OR (vice versa)

SELECT COLUMN_NAME FROM TABLE_NAME WHERE COLUMN_NAME IN ('A' , 'stu' ,'Meyer', ....);

How can I exclude in notepad++ the single quotation marks part (from replacement)?

(I find the single quotation marks part with e.g. '(.*?)' or '(\w+)' or '[[:alpha:]]{1,}',..)

I'm happy for every answer, also if you don't use notepad++!

我有这样一根绳子:

SELECT column_name FROM table_name WHERE column_name IN ('A' , 'stu' ,'Meyer', ....);

我想替换所有的字符在记事本+ +从上到下(或反之亦然),但,排除更换,字符内的单引号。

条件:在单引号部分之前/后面不存在实体结构!

(That means - I can not use the keyword "IN" or signs like "," or "(" or ")" or ";" for this regex ...!)

目标字符串(单引号内的字符必须保持unchangend):

select column_name from table_name where column_name in ('A' , 'stu' ,'Meyer', ....);

或(反之亦然)

SELECT COLUMN_NAME FROM TABLE_NAME WHERE COLUMN_NAME IN ('A' , 'stu' ,'Meyer', ....);

我怎样才能排除在记事本+ +单引号部分(从更换)?

(我发现单引号的一部分,例如“(?*))或“(+瓦特+)”或[ [:阿尔法:] { 1,},,…)

我很高兴每一个答案,也如果你不使用记事本+!

answer1: 回答1:

Below regex would match all the uppercase letters which are not present inside single quotes.

[A-Z](?=(?:'[^']*'|[^'\n])*$)

Now, right-click on the matched characters and change it to lowercase.

DEMO

下面的正则表达式将匹配所有大写字母不出现在单引号。

[A-Z](?=(?:'[^']*'|[^'\n])*$)

现在,右键单击匹配的字符并将其改为小写。

演示

regex  notepad++  regex-negation  regex-lookarounds