79470753

Date: 2025-02-26 18:39:04
Score: 1
Natty:
Report link

you can achieve this with:

$pattern = '/\[(?!")([^]]+)(?<!")\]/';
$replacement = '["$1"]';
$new_string = preg_replace($pattern, $replacement, $old_string);

the preg_replace will search for the pattern in the old string and replace following the pattern defined

PS.: this site is excellent to test regex patterns

Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Gabriel MGFC-DEV