Search code examples
regexpowershell-2.0powershell-3.0

Replace the delimiter string in Json file


I have the json file with the delimiter values in it, I have to replace the delimeter($$....$$) with another delimiter value.

This is the input file

{ parameters: { "key" : "$$value$$" } }

Expected value is below. { parameters: { "key" : "$(value)" } }


Solution

  • This expression,

    "key"\s*:\s*"\$\$([^$]*)\$\$"
    

    with a replacement of

    "key":"$($1)"
    

    might be an option.


    If you wish to explore/simplify/modify the expression, it's been explained on the top right panel of regex101.com. If you'd like, you can also watch in this link, how it would match against some sample inputs.