I have some regex patterns stored as strings inside a PHP array. I need them to be outputted as JavaScript RegExp objects. Is there any way to do this by using PHP's json_encode
?
Example:
$array = [
'regex' => '/some-regex/'
];
return json_encode( $array );
Desired output:
{"regex": /some-regex/}
Current output:
{"regex": "/some-regex/"}