Reputation: 3086
It is possible to do a conditional find and replace in sublime text? I want to remove the external div class = "key-actions" but keep anything within them. The problem is the internal content will always be the same with maybe 3 different links at times
// this becomes
<div class="key-actions">
<a href="one-link.html"><div class="btn btn-primary btn-block text-left"><i class="icon-chevron-sign-right icon-showhouse2"></i> One Link</div></a>
<a href="two-link.html"><div class="btn btn-primary btn-block text-left"><i class="icon-chevron-sign-right icon-showhouse2"></i> Two Link</div></a>
</div>
// this
<a href="one-link.html"><div class="btn btn-primary btn-block text-left"><i class="icon-chevron-sign-right icon-showhouse2"></i> One Link</div></a>
<a href="two-link.html"><div class="btn btn-primary btn-block text-left"><i class="icon-chevron-sign-right icon-showhouse2"></i> Two Link</div></a>
Upvotes: 1
Views: 1436
Reputation: 11557
This is kind of dependent on your code formatting, in particular the position of your new lines, but the following works for your example.
Find what:
(?s)<div class="key-actions">(.+?)\n</div>
Replace with:
\1
This will only work if there are no divs inside <div class="key-actions">
that close on a new line.
Upvotes: 2