I need to replace the contents inside all <div class="definition">text here</div>
with "...", but not if any {
or }
is found within. I've tried this with perl
, but it seems to be deleting too much, sometimes finding the first <div>
and last </div>
:
perl -pe 's/<div class="definition">[^{].*[^<]<\/div>/<div class="definition">...<\/div>/g'
E.g.:
This is a file <div class="definition">text here</div>.
This is a file <div class="definition">{text here}</div>. This is a file <div class="definition">text here</div>.
This is a file <div class="definition">text here</div>.
Output:
This is a file <div class="definition">...</div>.
This is a file <div class="definition">{text here}</div>. This is a file <div class="definition">...</div>.
This is a file <div class="definition">...</div>.
How can I replace any content there, but not if {
or }
are found inside?