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>
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.