FIND TEXT BETWEEN TAGS – SUBLIME TEXT

Published: 29, Apr 2015
Development

Often you may want to change all text between certain tags within Sublime Text, remove all types of certain tags, or change all of one HTML Tag to another. This is very often the case in XML documents or if you are removing all comments.

This is easily done, thanks to the Regular Expression option within Sublime Text’s find options. Use the following code, and ensuring “regular expression” icon is checked (Check screenshot below).

This code byte will find all h2 tags within a document, from opening to closing tag, as well as content inbetween.

(?s)(?<=)(.+?)(?=

This is really useful to find all HTML comments and remove them in Sublime Text!
This one will find all comments, you can then use CMD + Shift + G(Quick Find All) To highlight all of them, and delete if you wish, or change them all simultaneously.

Change it to match your needs.