Value Year (\d+)
Value Timezone (\S+)
Value MonthDay (\d+)
Value Month (\w+)
Value Time (..:..:..)
Start
^${Time}.* ${Timezone} \w+ ${Month} ${MonthDay} ${Year} -> Record
This is a template for texfsm which does parsing of cli based responses with a regex template. Heres the return from javascripts json.stringify
{"template":"Value Year (\\d+)\nValue Timezone (\\S+)\nValue MonthDay (\\d+)\nValue Month (\\w+)\nValue Time (..:..:..)\n\nStart\n ^${Time}.* ${Timezone} \\w+ ${Month} ${MonthDay} ${Year} -> Record"}
I want to write this template on the front end and then send it to my server for processing. I've used json.stringify() but when try and use json.loads() in python it compains about improperly escaped characters.
ValueError: Invalid \escape: line 1 column 83 (char 82)
How can I properly escape this template for json to then unescape it and use it on my server in python?
--
As a side note.
I've seen here how to escape regex ( Is there a RegExp.escape function in Javascript?) though I'm a bit unsure on how to unescape it.