3

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

ora_job
  • 103
  • 7
  • If you just want to convert before opening `(` search for `^(.*?\()` and replace with `\U\1` or lower: `\L\1` – Jonny 5 Aug 15 '15 at 15:34

1 Answers1

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

Community
  • 1
  • 1
Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
  • 1
    many, many thanks (also for your effort) - that is what I needed - perfect – ora_job Aug 16 '15 at 04:56
  • I know it's probably obvious, but how do you select the text using that regex? I tried `Search-Mark...`, and it does mark the text but doesn't select it so I can convert the case. – localhost Aug 21 '17 at 01:10