简体   繁体   中英

Ask the help for regular expressions in Android

I am a beginner on developing Android's application. I have some problems about using regular expressions in 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. And now I want to use regular expressions to retrieve some details in the html tags of this page. So, what should I do for it?

for example, in the html code,

<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. Can anyone teach me how I can do it? Or you may give me some reference page for it with Android. Thank you very much.

HTML is not a regular language, therefore you cannot use Regular Expressions against it 100% successfully. You need to use some sort of HTML parser instead.

You don't want to be driven insane.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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