Good morning!
I've encountered an issue with a JavaScript regular expression that I can't seem to troubleshoot.
My script is making a call to the API provided by , and receiving a JSON response containing monitor statuses. However, this JSON string is wrapped in a function call syntax like this:
jsonUptimeRobotApi({MASKED-STATUES-OBJ})
Since this call is part of a generic script, I wanted to test the response to check for this specific syntax wrapping so I could parse it properly.
But unfortunately, my attempts to create a regex pattern that matches the required logic have been unsuccessful:
- Start of string
- An unknown number of characters [a-zA-Z]
- Open parentheses
- Open brace
- An unknown number of any character
- Close brace
- Close parentheses
- End of string
My regex pattern currently looks like this:
^[a-zA-Z]+\(\{.*\}\)$
It seems to work in regex101: https://regex101.com/r/sE7dM6/1
However, when implemented in my code and tested on jsFiddle: https://jsfiddle.net/po49pww3/1/
I had to add the "m" in regex101 due to the actual length of the string, but even after tweaking, I couldn't get it to match in jsFiddle.
Does anyone have insights into what might be causing this issue?