I propose this:
sed 's;^[[:blank:]]*<.*>[[]]*<[^>]*>[[:blank:]]*\(.*\)<.*>.*;\1;'*$;\1;' foo Output:
Text here that I want to keep This works if the tags have more than one letter, and any letter, and removing any white space at begginig and end, example:
<br> Text here that I want to keep </br> (31ca4166c37a_.76)