perl脚本查找匹配指定的字符串失败?

我有一段文本,想从中取出Email:后面的电子邮箱和Mobile:后面的手机号。

<div class="person_item">
<div class="person_attr_name">Business title: </div>
<div class="person_attr_value">Advisory Engineer</div>
</div>
<div class="person_item">
<div class="person_attr_name">Email: </div>
<div class="person_attr_value"><a href="mailto:joe.wang@goole.com">joe.wang@goole.com</a></div>
</div>
<div class="person_item">
<div class="person_attr_name">CSLogin: </div>
<div class="person_attr_value">joew</div>
</div>
<div class="person_item">
<div class="person_attr_name">Handle: </div>
<div class="person_attr_value">joew</div>
</div>
...
<div class="person_item">
<div class="person_attr_name">Phone: </div>
<div class="person_attr_value">
<span class="telnum">+8621545045550000</span>
</div>
</div>
<div class="person_item">
<div class="person_attr_name">Other Phone: </div>
<div class="person_attr_value">
<span class="telnum">27440000</span>
</div>
</div>
<div class="person_item">
<div class="person_attr_name">Mobile: </div>
<div class="person_attr_value">
<span class="telnum">+8613618580000</span>
</div>
</div>
<div class="person_item">
<div class="person_attr_name">Assistant: </div>
<div class="person_attr_value">
<span class="telnum">+86 21545045550000</span>
</div>
</div>

我用if (/Mobile: </div>n<div class="person_attr_value">n<span class="telnum">+(.+)</span>.*$/) { $mobile = $1; }无法取出。
如果用if (/span class="telnum">+(.+)</span>.*$/) { $mobile = $1; }可以取出+86 21545045550000,并不是我想要的手机号。
请问我的匹配命令错在哪里?应该如何修改呢?
电子邮箱又应该如何取呢?

阅读 2.9k
1 个回答
  if (/Mobile: /../<span class=\"telnum\"\>+(.+)\<\/span\>.*$/)   { $mobile = $1; }
         if (/Email: /../href=\"mailto:+(.+)\"\>.*$/)   { $email = $1; }
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进