$re = '/[\s]+<\/coordinates>[\s\S]+?<coordinates>[\s]+/m';
$str = '<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<name>Example.kml</name>
<Style id="s_ylw-pushpin_hl">
<IconStyle>
<scale>1.3</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
<LineStyle>
<color>ffff00ff</color>
<width>4</width>
</LineStyle>
</Style>
<StyleMap id="m_ylw-pushpin">
<Pair>
<key>normal</key>
<styleUrl>#s_ylw-pushpin</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#s_ylw-pushpin_hl</styleUrl>
</Pair>
</StyleMap>
<Style id="s_ylw-pushpin">
<IconStyle>
<scale>1.1</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
<LineStyle>
<color>ffff00ff</color>
<width>4</width>
</LineStyle>
</Style>
<Folder>
<name>Example</name>
<open>1</open>
<Placemark>
<name>Untitled Path</name>
<styleUrl>#m_ylw-pushpin</styleUrl>
<LineString>
<tessellate>1</tessellate>
<coordinates>
1.010794386877401,44.51240983736842,0 0.6286744887979312,47.46969863211312,0 4.198175193521713,47.66272708685459,0 4.47650525274385,45.32855385904715,0
</coordinates>
</LineString>
</Placemark>
<Placemark>
<name>Untitled Path</name>
<styleUrl>#m_ylw-pushpin</styleUrl>
<LineString>
<tessellate>1</tessellate>
<coordinates>
8.904276108011693,51.53463622874661,0 9.185337211508118,53.24757135457648,0 12.82197202867711,52.85957127892767,0 9.326760498064647,50.5694391186729,0
</coordinates>
</LineString>
</Placemark>
<Placemark>
<name>Untitled Path</name>
<styleUrl>#m_ylw-pushpin</styleUrl>
<LineString>
<tessellate>1</tessellate>
<coordinates>
-0.8457721243506866,53.25357789001806,0 -2.495344342945436,52.51894778278026,0 -1.832838168564855,51.68947925151446,0 -0.004852378987588724,51.90053296811562,0
</coordinates>
</LineString>
</Placemark>
</Folder>
</Document>
</kml>
';
$subst = " ";
$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