# If you'd like to omit non-matching lines from the result; add ';d' to the end of the expression.
sed -E 's/<span class="italics">([^<]*?)<\/span>/<em>\1<\/em>/g;t' <<< "What I am trying to do is to change all instances of <span class=\"italics\">italicised text here</span> to <em>italicised text here</em> where the text in the middle changes throughout the document. I can't just find replace, because there are 598 instances of <span class=\"italics\">, and 700 cases of </span>. Also, I want to learn how to do the find replace with leaving the stuff in the middle alone.
Do I use (.+?) at some point? I've been googling but unable to figure it out. Thank you in advance for your help!
Okay, your string finds the 598 I need to replace in my document, what can I add to the ([\S\s]*?) to get it to replace the span tags and leave the text between the span tags alone? For example, if it's <span class=\"italics\">The New York Times</span> and <span class=\"italics\">The Hitchhiker's Guide to the Galaxy</span>, is it possible to change those to <em\">The New York Times</em> and <em>The Hitchhiker's Guide to the Galaxy</em> in one go, or do I have to do them individually?"
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for SED, please visit: https://www.gnu.org/software/sed/manual/html_node/The-_0022s_0022-Command.html