Search code examples
regexnotepad++

Replace a character in all JSON values in a dict in Notepad++ using regex


My goal is to replace 1 case-sensitive character in all the values in a JSON file but not the keys.

So my thought process is like this:

  1. Highlight the part I want using: (?<=\:)(.*?)(?=\,)

  2. Search for just "R": (?<=\:)(.*?)(.R)(?=\,)

Step 2 should work but doesn't?

Something that replaces it with "T"

This is the input:

{
Hello: Rool,
MyKey1: Something
}

This is the expected output:

{
Hello: Tool,
MyKey1: Something
}

I appreciate any help I can get with this.


Solution

  • Try this ....
    Find: (?<=: )R(.*?)(?=,)
    Replace with: T$1

    Or without using captured group ...

    Find: (?<=: )R(?=.*?,)
    Replaced with: T