简体   繁体   English

向帮助寻求Android中的正则表达式

[英]Ask the help for regular expressions in Android

I am a beginner on developing Android's application. 我是开发Android应用程序的初学者。 I have some problems about using regular expressions in Android. 我在Android中使用正则表达式存在一些问题。

In my application, I had write some code for get back the source code of a html page which I had turn it in String datatype. 在我的应用程序中,我编写了一些代码来获取HTML页面的源代码,并将其转换为String数据类型。 And now I want to use regular expressions to retrieve some details in the html tags of this page. 现在,我想使用正则表达式来检索此页面的html标记中的一些详细信息。 So, what should I do for it? 那么,我该怎么办呢?

for example, in the html code, 例如,在html代码中,

<HTML>
.......
<TABLE class=tb_info cellSpacing=0 cellPadding=0 border=0>
<TR>
<TD class=pro_name vAlign=center colSpan=5>Abby Poon</TD>
</TR>
<TR>
<TD class=pro_name vAlign=center colSpan=5>Peter Pan</TD>
</TR>
</TABLE>
.........
</HTML>

And now I want to get back the value "Abby Poon" and "Peter Pan" which is in a table called "tb_info" and in a called "pro_name" for both two values. 现在,我想取回值“ Abby Poon”和“ Peter Pan”,这两个表在一个名为“ tb_info”的表中,在一个名为“ pro_name”的表中。 Can anyone teach me how I can do it? 谁能教我该怎么做? Or you may give me some reference page for it with Android. 或者,您可以在Android上给我一些参考页。 Thank you very much. 非常感谢你。

HTML is not a regular language, therefore you cannot use Regular Expressions against it 100% successfully. HTML不是常规语言,因此您不能100%成功地对其使用正则表达式。 You need to use some sort of HTML parser instead. 您需要改用某种HTML解析器。

You don't want to be driven insane. 您不想被疯狂。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM