What does this perl regex to read server JSON reply do?

Viewed 62

I am reading some code that parses the json return from a web site, a Dynamic DNS provider if it matters.

 $reply =~ qr/{(?:[^{}]*|(?R))*}/mp;

What will this match?

I am reading this https://perldoc.perl.org/perlretut to try and understand. So far I understand the following

It will match something that starts with '{' and ends with '}'.

(?: means not to extract the regexp. I assume this is for speed?

Then it will match something that is not '{' or '}' as many times (e.g. fjksfksdh) which is not necessarily proper JSON syntax as far as I can tell.

Then I have no idea what is the meaning of ?R and I struggle putting it all together in the end.

Can someone help me out?

Sorry perl and JSON noob here.

0 Answers
Related