解析正则表达式中缺少结束符的帮助标签
我需要检索 table tag 之间的所有数据。但最近由于现场的一些更新,他们忘记在其中一张表格中包含结束标签。 原始源代码位于此处:
<table><tr><td><b>Semester:</b></td><td><b>5</b></td><td></td><td> <b> Result: SECOND CLASS </b></td></tr></table><hr>
<table><tr><td width=250>Subject</td><td width=60 align=center>External </td><td width=60 align=center>Internal</td><td align=center width=60>Total</td><td align=center width=60>Result</td></tr><br><tr><td width=250><i>Software Engineering (06IS51)</i></td><td width=60 align=center>45</td><td width=60 align=center>19</td><td width=60 align=center>64</td><td width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Systems Software (06CS52)</i></td><td width=60 align=center>48</td><td width=60 align=center>20</td><td width=60 align=center>68</td><td width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Operating Systems (06CS53)</i></td><td width=60 align=center>37</td><td width=60 align=center>21</td><td width=60 align=center>58</td><td width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Database Management Systems (06CS54)</i></td><td width=60 align=center>38</td><td width=60 align=center>19</td><td width=60 align=center>57</td><td width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Computer Networks - I (06CS55)</i></td><td width=60 align=center>58</td><td width=60 align=center>20</td><td width=60 align=center>78</td><td width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Formal Languages & Automata Theory (06CS56)</i></td><td width=60 align=center>58</td><td width=60 align=center>21</td><td width=60 align=center>79</td><td width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Database Applications Laboratory (06CSL57)</i></td><td width=60 align=center>49</td><td width=60 align=center>20</td><td width=60 align=center>69</td><td width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Algorithms Laboratory (06CSL58)</i></td><td width=60 align=center>20</td><td width=60 align=center>18</td><td width=60 align=center>38</td><td width=60 align=center><b>P</b></td></tr><br><br><hr>
<table><tr><td><b>Semester:</b></td><td><b>3</b></td><td></td><td> <b> Result: SECOND CLASS </b></td></tr></table><hr>
<table><tr><td width=250>Subject</td><td width=60 align=center>External </td><td width=60 align=center>Internal</td><td align=center width=60>Total</td><td align=center width=60>Result</td></tr><br><tr><td width=250><i>Electronic Circuits (06CS32)</i></td><td width=60 align=center>35</td><td width=60 align=center>15</td><td width=60 align=center>50</td><td width=60 align=center><b>P</b></td></tr></table><br><br>
<table><tr><td></td><td></td><td>Total Marks:</td><td> 50 </td></tr></table>
我使用下面的正则表达式进行匹配,它工作正常,但您可以注意到最近的更新忘记了在第二个表元素中包含表的结束标记,并且它破坏了代码。
"|<table>.*<\/table>|U"
请帮助我形成一个表达式来匹配表之间的数据。 任何帮助将不胜感激。 谢谢。
I am required to retrieve all the data between table tag . but recently due to some update on site they forgot to include a closing tag in one of the tables.
Original source code goes here:
<table><tr><td><b>Semester:</b></td><td><b>5</b></td><td></td><td> <b> Result: SECOND CLASS </b></td></tr></table><hr>
<table><tr><td width=250>Subject</td><td width=60 align=center>External </td><td width=60 align=center>Internal</td><td align=center width=60>Total</td><td align=center width=60>Result</td></tr><br><tr><td width=250><i>Software Engineering (06IS51)</i></td><td width=60 align=center>45</td><td width=60 align=center>19</td><td width=60 align=center>64</td><td width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Systems Software (06CS52)</i></td><td width=60 align=center>48</td><td width=60 align=center>20</td><td width=60 align=center>68</td><td width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Operating Systems (06CS53)</i></td><td width=60 align=center>37</td><td width=60 align=center>21</td><td width=60 align=center>58</td><td width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Database Management Systems (06CS54)</i></td><td width=60 align=center>38</td><td width=60 align=center>19</td><td width=60 align=center>57</td><td width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Computer Networks - I (06CS55)</i></td><td width=60 align=center>58</td><td width=60 align=center>20</td><td width=60 align=center>78</td><td width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Formal Languages & Automata Theory (06CS56)</i></td><td width=60 align=center>58</td><td width=60 align=center>21</td><td width=60 align=center>79</td><td width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Database Applications Laboratory (06CSL57)</i></td><td width=60 align=center>49</td><td width=60 align=center>20</td><td width=60 align=center>69</td><td width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Algorithms Laboratory (06CSL58)</i></td><td width=60 align=center>20</td><td width=60 align=center>18</td><td width=60 align=center>38</td><td width=60 align=center><b>P</b></td></tr><br><br><hr>
<table><tr><td><b>Semester:</b></td><td><b>3</b></td><td></td><td> <b> Result: SECOND CLASS </b></td></tr></table><hr>
<table><tr><td width=250>Subject</td><td width=60 align=center>External </td><td width=60 align=center>Internal</td><td align=center width=60>Total</td><td align=center width=60>Result</td></tr><br><tr><td width=250><i>Electronic Circuits (06CS32)</i></td><td width=60 align=center>35</td><td width=60 align=center>15</td><td width=60 align=center>50</td><td width=60 align=center><b>P</b></td></tr></table><br><br>
<table><tr><td></td><td></td><td>Total Marks:</td><td> 50 </td></tr></table>
I used the below regualr expression to match and it was working fine but as you can notice the recent update has forgot to include closing tag of table is in second table element and it is breaking the code.
"|<table>.*<\/table>|U"
Kindly help me to form a expression to match the data between tables .
Any help will be highly appreciated.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您实际上可以决定获取从第一个
标记到最后一个
< 的数据,而不是在
标记之间获取数据。 ;/tr>(包含)
Instead of getting the data between the
<table>
tags, you could actually decide to take data starting from the first<tr>
tag to the last</tr>
(inclusive)