Using SED to substitute between two patterns.

Hi All,

I'm currently using SED to make various changes to some .xml files I'm working on, but I'm stuck on this particular problem.

I want to remove '<placeholder>element-name</placeholder>' from the following:

<heading>Element <placeholder>element-name</placeholder> not recognized</heading>

This type of pattern is repeated in several of my files so essentially I'm looking to remove the placeholder tags and whatever is enclosed.

Any help greatly appreciated.

If you have access to Perl, this should point you in the right direction:

perl -pe 's/(.*)<placeholder>.*<\/placeholder>\s(.*)/$1$2/g' file.xml

Returns:
<heading>Element not recognized</heading>

Hope this helps.

Fantastic. That works a treat. I've not thought about using Perl before. Perhaps it's time I took a look at it!

Thanks for your help.