替换notepad ++中的字符,但排除单引号内的字符 [英] replace characters in notepad++ BUT exclude characters inside single quotation marks

查看:669
本文介绍了替换notepad ++中的字符,但排除单引号内的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的字符串:

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!

(这意味着-我不能使用关键字"IN"或,"或("之类的符号 或)"或;"为此正则表达式...!)

(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(反之亦然)

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

如何在记事本++中排除单引号部分(替换中)?

(我发现单引号的部分是'(.*?)'或'(\ w +)'或'[[:alpha:]] {1,}',..)

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

推荐答案

以下正则表达式将匹配单引号中不存在的所有大写字母.

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

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

现在,右键单击匹配的字符并进行更改小写.

演示

这篇关于替换notepad ++中的字符,但排除单引号内的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆