问题
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