$re = '/("UID\s*([^\n\r]*))/m';
$str = '{
"Tabelle1": [
{
"Nr.": "1",
"Firma": "Alba Reisen/Versicherungen/Darlehen H. Kajtazi",
"Rechtsform": "EIU",
"Sitz": "Rapperswil-Jona",
"Kanton": "SG",
"UID": "CHE‑101.868.757"
},
{
"Nr.": "2",
"Firma": "Alybaba - Schischa Laden, Aly",
"Rechtsform": "EIU",
"Sitz": "Wil (SG)",
"Kanton": "SG",
"UID": "CHE‑102.012.121"
},
{
"Nr.": "3",
"Firma": "Bluamawerkstatt zur Linde Marianne Bislin-Lieberherr",
"Rechtsform": "EIU",
"Sitz": "Pfäfers",
"Kanton": "SG",
"UID": "CHE‑217.602.289"
},
]
}
';
$subst = "$1,\"X\":\"\"";
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php