replace characters in notepad++ BUT exclude characters inside single quotation marks(4th)

给你一囗甜甜゛ 提交于 2019-12-11 11:48:07

问题


In

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

"Jonny 5" solved this question - BUT - if I have a construct like this:

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

then the target should be:

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

but the result is (The rest is o.k.!):

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

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

conditions: (same like in) replace characters in notepad++ BUT exclude characters inside single quotation marks(2nd)

It happens also, if I exchange the lines (1) and (2)!

How can I change this REGEX in notepad++ that ALL UPPER signs change to lower signs - exclude inside single quotation marks?


回答1:


The actual problem with the previous regex is that ' ' was considered as an opening delimiter, and the whole text from ' ' up to '' was "protected" with the subroutine call.

Use

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

The (?=\w) look-ahead makes sure that after the innermost starting ' is followed by a word character. If there can be again a space, you may replace this look-ahead with (?=\s*\w).



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

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