dtkago3208 2013-05-23 18:34
浏览 168
已采纳

将strpos与正则表达式结合起来

Here's the skinny. I'm using imap to get into Gmail, and using that for database entries. I'm having quite the headache of it to. The main issue is that I'm getting all sorts of random '=''s in my body. I can get around most of it, but the headache comes from primarily one source. I'm isolating out JUST the reply, and the email body is similar to this.

<div dir="ltr">Quick Quick! He's Drowning!!!!!!</div><div class="gm=
ail_extra"><br clear="all"><div>Thank you<div>Daniel Jenkins</div><div>Te=
chnical Assistant</div><div><a href="[url]" target="_blank">=
[work]</a><br>
</div><div>[phone number here]</div></div>
<br><br>

Now, I don't need the email signature, I just need the part before it. What I'm trying to do is strpos the <div class="gmail_ extra line, but it's a moving target because of the =. It's been after the a, the l, the g, etc. Is there a way to strpos(<div calss=g[=]?m[=]?a[=]?i[=]?l[=]?)?

  • 写回答

1条回答 默认 最新

  • doulang6695 2013-05-23 18:43
    关注

    The ending = is a soft return / newline in quoted-printable encoding, just use:

    $string = quoted_printable_decode($string);
    

    ... which will also take care of other unexpected differences between encoded body & actual content. After that you should have nice predictable HTML (which you would run through a parser rather then trying to split it with a regex).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Fluent udf 编写问题
  • ¥15 求合并两个字节流VB6代码
  • ¥15 Pyqt 如何正确的关掉Qthread,并且释放其中的锁?
  • ¥30 网站服务器通过node.js部署了一个项目!前端访问失败
  • ¥15 WPS访问权限不足怎么解决
  • ¥15 java幂等控制问题
  • ¥15 海湾GST-DJ-N500
  • ¥15 氧化掩蔽层与注入条件关系
  • ¥15 Django DRF 如何反序列化得到Python对象类型数据
  • ¥15 多数据源与Hystrix的冲突