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

空扰寡人 提交于 2019-12-20 02:54:16

问题


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++!


回答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



来源:https://stackoverflow.com/questions/32025638/replace-characters-in-notepad-but-exclude-characters-inside-single-quotation-m

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!