替换记事本中的字符++但是在单引号内排除字符(第4个)

时间:2015-09-02 08:00:13

标签: regex notepad++ regex-lookarounds

replace characters in notepad++ BUT exclude characters inside single quotation marks(2nd)

" Jonny 5 "解决了这个问题 - 但是 - 如果我有这样的结构:

SELECT column_name FROM table_name WHERE column_name IN ('A' , 'st9u' ,'Meyer', ....);
WHERE    a.object_type IN (' 'TABLE'', ''MATerialIZED VIE3W'   ')
vpl_text := IS_GOING_SMALL_CORRECT

(1) vpl_text := TO_CHAR(vpl_text_old) || '    ' ||...;
-- ------
vpl_text := STAYS_UPPER_ERROR

(2) vpl_text := TO_CHAR(vpl_text_old) || '' ||...;
-- ------

vpl_text := IS_GOING_SMALL_CORRECT

那么目标应该是:

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

(1) vpl_text := to_char(vpl_text_old) || '    ' ||...;
-- ------
vpl_text := stays_upper_error

(2) vpl_text := to_char(vpl_text_old) || '' ||...;
-- ------

vpl_text := is_going_small_correct

结果是(其余的是 o.k。!):

:
-- ------
vpl_text := STAYS_UPPER_ERROR

(2) vpl_text := TO_CHAR(vpl_text_old) || '' ||...;
-- ------
:
  

条件:(同样如此)   replace characters in notepad++ BUT exclude characters inside single quotation marks(2nd)

     

如果我更换第(1)和(2)行,也会发生这种情况!

如何在记事本++中更改此REGEX,ALL UPPER符号会变为较低的符号 - 在单引号内排除?

1 个答案:

答案 0 :(得分:1)

以前的正则表达式的实际问题是' '被视为开头分隔符,' '''的整个文本是& #34;保护"与子程序调用。

使用

'\s*(?0)?(?=\w)[^']*'\K|(\w+)

(?=\w)前瞻确保在最里面的起始'后跟一个单词字符。如果可以再次存在空格,则可以使用(?=\s*\w)替换此预测。