[英]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 在这里测试: http : //codepad.org/I1Ddfwte
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.