Escaping Regex to get Valid JSON

Its just the slashes that are messing up the validation you could encode them using %5C which is the hex encoding of \ or what Mike W says you could double escape like \\ and then you could just decode them when you want to use them


The accepted answer doesn't work for me. %5C doesn't work well with a linter. Plus manually doing it is a job. How about a very long regex -

^(([^<>()[\\]\\.,;:\\s@\"]+(\\.[^<>()[\]\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$

So, please don't kill yourself and head to this get this done - https://www.freeformatter.com/json-escape.html#ad-output

In case the link doesn't work in future, please find some other online tool :)

Tags:

Json

Schema