regex - Javascript Regular Expression not matching -
morning all
i have javascript regular expression doesn't work correctly , i'm not sure why.
i'm calling api @ https://uptimerobot.com, , getting json string details of monitor statues. wrapped in function call syntax. this:
jsonuptimerobotapi({masked-statues-obj})
as call being made generic script hoping test response see if had type of syntax wrapping parse accordingly.
however can't seem find regex syntax match logic:
- start of string
- an unknown number of characters [a-za-z]
- open parentheses
- open brace
- an unknown number of character
- close brace
- close parentheses
- end of string
this looks right:
^[a-za-z]+\(\{.*\}\)$
and works in regex101: https://regex101.com/r/se7dm6/1
however fails in code , via jsfiddle: https://jsfiddle.net/po49pww3/1/
the "m" added in regex101 actual string longer, , failed match without it, number of small tweeks i've tried havn't resulted in match in jsfiddle.
anyone know whats wrong?
escape backslashes 1 more time because within "
delimiters, must escape backslash 1 more time or otherwise treated escape sequence.
var regex = new regexp("^[a-za-z]+\\(\\{.*\\}\\)$", "m");
Comments
Post a Comment