This question already has an answer here:
I am trying to remove signature of an email before inserting the message into a database. The signature is enclosed in a special tag, xxx to help strip out.
The following only works if the signature is condensed without whitespace spread over various lines.
$msgeBody = preg_replace('#(<signature>).*?(</signature>)#', '$1$2', $msgeBody);
I have tried possibilities found online to remove whitespace first between these tags, before applying the line above. But no success. How to do? Here is the sample text spread over lines:-
<signature><p><span style="font-weight: bold;">Gerald Sugan</span><br>
Travel Consultant<br>
<span style="font-size: 18px; font-family: 'Courier New'; font-weight: bold;">Sugan Enterprises Inc</span></p>
</signature>
The solution of php preg_replace regex that matches multiple lines is not a duplicate. I could not see how to apply those solutions here. The solution found below is different I think.
</div>