2012-02-24 89 views
0

所以即时通讯试图找出在Flex中的正则表达式,但不能为我的生活弄清楚如何做到以下几点。 从下面的示例中,我只需要提取出“Mike_Mercury”。如何使用正则表达式来提取子字符串?

所以我必须以某种方式将RegExp或其他任何最好的东西去掉。另外,我也需要它与其他样品一起工作。我从reddit api得到这个,所以ID必须从一大堆这些中提取相同的部分。谢谢!

<table> 
      <tr> 
       <td> 
        <a href="http://www.reddit.com/r/atheism/comments/q2sfe/barack_obamas_insightful_words_on_abortion/"> 
         <img src="http://d.thumbs.redditmedia.com/9StfiHi7hEbf8v73.jpg" alt="Barack Obama's insightful words on abortion" 
          title="Barack Obama's insightful words on abortion" /></a> 
       </td> 
       <td> 
        submitted by <a href="http://www.reddit.com/user/Mike_Mercury">Mike_Mercury </a> 
        to <a href="http://www.reddit.com/r/atheism/">atheism</a> 
        <br /> 
        <a href="http://imgur.com/lKFYr">[link]</a> <a href="http://www.reddit.com/r/atheism/comments/q2sfe/barack_obamas_insightful_words_on_abortion/"> 
         [1722 comments]</a> 
       </td> 
      </tr> 
     </table> 
+1

使用HTML解析器。正则表达式不会解析任意的HTML。 – Blender 2012-02-24 05:10:00

+0

这仍然是HTML;) – Blender 2012-02-24 05:19:14

回答

1

试试这个正则表达式:

submitted by <a href=".*?">(.*?)</a> 
相关问题