Omi
Omi

Reputation: 4017

Need regular expression to match specific pattern in notepad++

I want search for specific pattern like 'constant_string' : some_string. 'constant_string' : this will be constant part in pattern & some_string it may change.

I want to find for this pattern 'constant_string' : some_string and replace with 'constant_string' : 'some_string'. (single quote added to some_string)

Upvotes: 0

Views: 40

Answers (1)

Dhananjai Pai
Dhananjai Pai

Reputation: 6005

Try using:

(?<='constant_string' \: )([A-Za-z0-9_]*)

And replace with:

'\1'

Captures the string into a capturing group and uses it to replace the quoted value

Demo : https://regex101.com/r/Hl3Zpe/1

Better Method:

('constant_string' \: )([A-Za-z0-9_]*)

Replace with

'\2'

Using 2 here, since there are two capturing groups and \1 is now constant_string : and the variable string is in \2

Upvotes: 1

Related Questions