Find and Replace functionality with new line inserted does not work

amursa
I need to substitute part of the body request with 2 json key-values pairs. I figured out the find regexp using https://regex101.com/ and it works, but I can’t find how do I add new line in substitution string. Could you pls suggest?
for example [\r\n\t\v]+”key1″: “value1”,[\r\n\t\v]+. to be replaced with “key1”: “value1”,\n “key2”: “value2”,\n.
It does not interpret \n and uses it as a string, unfortunately.

So, I need a two line substitution, like:
“key1”: “value1”,
“key2”: “value2”

Heu Amursa,

so this is mostly a JS question since Postman doesn’t have an area to do regex directly.
Can you provide the script example in which you use this in?

I have part of my json looking like this:
“key1”:[“value 1”, “value 2”],

I find it with this regexpt THAT WORKS JUST LIKE I NEED:
^“key1”:\s?[“value\s?[0-9]+”\s?,\s?“value\s?[0-9]+[”]],\n+?
“key1”:[“value 1”, “value 2”], \n “key2”: ["test1],

In the find replace POSTMAN tab I provide in replace following string:
“key1”:[“value 1”, “value 2”], \n “key2”: ["test1],
Substitution does not interpret \n and results is in one line:
“key1”:[“value 1”, “value 2”], \n “key2”: ["test1],

so you are trying this in the find and replace tab, ok thank you.

Trying your examples in Regex101 seem to select but you should be testing using Javascript.

so for example:

const regext = /[\r\n\t\v]+"key1": "value1",[\r\n\t\v]+/gm;
regext.test(v)

where v is your string. Following your example I’m getting false.
I wonder if you have to escape your \n ?

Hi Kyle, I’m able to find my string with no problem. Substitution is the issue. How do you tell postman to insert new line cause \n is not working.