I have a text similar to this:
<p>some text ...</p><p>The post <a href="http://url_address/">text...</a> appeared first on <a href="http://url_address">some another text</a>.</p>
I need to remove everything from <p>The post, so the results would be:
<p>some text ...</p>
I am trying ot do that this way:
text.sub!(/^<p>The post/, '')
But it returns just an empty string… how to fix that?
Your regex is incorrect. It matches every
<p>The postthat is in the beginning of the string. You want the opposite: match from its position to the end of the string. Check this out.