I have a long line of text and html tags. I wish to use sed to replace the characters between the string with the value 'MYSTART' up to the first occurance of </p>
after the starting string. The substituting text is RESULTSAFTERSUBSTITUTIONWORKS
I've been fumbling and bumbling with regular expressions and keep hitting a brick wall. I also tried a few regex test sites but what they report as success doesn't work in sed for me either with or without using the '-r'.
cat myfile | sed -r 's/MYSTART.*?<\/p>/RESULTAFTERSUBSTITUTIONWORKS/'
My sample string looks something like this:
THISSHOULDBEIGNORED_MYSTART<ac>blah</ac><another>lots of things 123 abc :</another></p><div><ac>another thing</another><p>welcome home to somewhere</p></div>the line keeps going and going</p><p>paragraph</p>
After substitution it would look like this:
THISSHOULDBEIGNORED_RESULTAFTERSUBSTITUTIONWORKS<div><ac>another thing</another><p>welcome home to somewhere</p></div>the line keeps going and going</p><p>paragraph</p>