-3
{
    "Regex": "^(Common)[_]\d+$|^(MP)[_][0-9a-f]{24}|.*((google)|(Common)|(gmail))+\.(com)$"
}

I am facing the above issue which I mentioned in the screenshot,enter image description here in postman while I am posting the payload which I provided with RegEx value. It is giving me the Error. Any suggestions guys. Please help out with this issue. Thank you

  • 1
    Do not post your code, error messages, or other pertinent debugging info as images - instead, paste it as text in the body of your question. Not only is it much easier and can be accomplished in less steps, but it helps when community members can copy and paste your code into another IDE to test it before providing an answer. [ask] – esqew Oct 05 '21 at 04:49
  • Does this answer your question? [How to escape special characters in building a JSON string?](https://stackoverflow.com/questions/19176024/how-to-escape-special-characters-in-building-a-json-string) – Christian Baumann Oct 05 '21 at 06:46

1 Answers1

2

Make it simple by adding it in pre-request

const regex = JSON.stringify("^(Common)[_]\d+$|^(MP)[_][0-9a-f]{24}|.*((google)|(Common)|(gmail))+\.(com)$")

pm.variable.set("regex",regex)

Now call this in body as

   {
    "Regex": "{{regex}}"
   }
PDHide
  • 18,113
  • 2
  • 31
  • 46