简体   繁体   中英

remove a character or characters from each line

can any one help me to solve this issue. problem with '>' symbol When emails are forwarded, some email clients will add “>” symbols before each line of the email. For example:

This is an example of forwarded text

Becomes:

> test message

If this is done many times, text can become unreadable:

>>>>>>>>>>>>>>>>>>> test message
>>>>>>>>>>>>>>>>> test message

There may even be spaces in between groups of “>” symbols, like this:

>> >>>>>> >>>>>>>>> test message

i need to remove these text from each line and clean the email content

anyone help me to find out a regular expression to fix this issue

$ trimmed = preg_replace('/ ^([> \\ s] +)/ m','',$ content);

function strip_forward($input) {
    return preg_replace("/^[> ]+/m","",$input); 
}

////////////////////////////////////////////////

$input = ">>> >> > Test\n".
         ">> Test\n".
         "> Test\n".
         "Test";

echo $input."\n\n\n";
echo strip_forward($input);

Test it here: http://codepad.org/I1Ddfwte

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM