Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Surround strings with quotes in Notepad++ using regex [duplicate]

I have below text line in Notepad ++

Type, Layer, Env, key, action, timestamp, performedBy, desc, 

I want to convert it to

'Type', 'Layer', 'Env', 'key', 'action', 'timestamp', 'performedBy', 'desc', 

I write in find [a-zA-Z]*, and it gives me each comma separated string what shall I enter in replace to have them surrounded by quotes?

like image 701
Neha Vari Avatar asked Dec 10 '22 07:12

Neha Vari


2 Answers

You can use ([a-zA-Z]*) in find and '\1' or '$1' in replace.

\1 or $1 (in newer versions of n++) means the first captured group.

See also this question.

like image 60
mrzasa Avatar answered Feb 23 '23 17:02

mrzasa


If you search for ([a-zA-Z]*), the () indicates a group you can reference later.

Now you can write '$1', in the replace dialog.

like image 38
jesper_bk Avatar answered Feb 23 '23 16:02

jesper_bk