I am editing a KML file that has info in it like:
<name>some name</name>
<description> some description and search target</description>
<styleUrl>#icon-960-DB4436</styleUrl>
<Point>
<coordinates>
34.7661563,32.059198,0
</coordinates>
</Point>
</Placemark>
I am trying to use a regex that will capture all the info from when begins until ends if some target string is present in the tag.
I tried this
<placemark>.*?search target.*?</placemark>
but ofcourse it will capture more than I need.
some help please?
Qualify dot with a negative lookahead for </Placemark>
to restrict searches to within such a tag.
To find the text DB4436
(from your example) use:
<Placemark>((?!<\/Placemark>).)*DB4436((?!<\/Placemark>).)*<\/Placemark>
with the DOTALL flag on (you haven't indicated the language/tool you're using, so I can't show how to specify that - it varies).
See live demo.