html正则表达式以及string带有参数
1.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<body>
<tablecellpadding="2"cellspacing="0"border="0"width="100%"class="light_box">
<tr>
<tdvalign=top><b>ExpiryDate:</b>11May2010</td>
<tdalign=right><b>CurrentPeriod:</b>Ends:11May2010
</td></tr>
<tr>
<tdcolspan=2> </td>
</tr></table>
</body>
</html>
StringregexDate="<b>ExpiryDate:</b>(.+?)</td>";
//StringregexDate="<b>ExpiryDate:<\\/b>";
Patternp=Pattern.compile(regexDate);
String[]items=p.split(returnedHTML);
System.out.println("*******REGEX1RESULT*******");//printswhateverthe.+?expressionmatched.
for(Strings:items)
{
System.out.println(s);
}
System.out.println("*******REGEX1RESULT*******");//printswhateverthe.+?expressionmatched.
Patternp2=Pattern.compile("<b>ExpiryDate:<\\/b>");
Matcherm=p2.matcher(returnedHTML);
if(m.matches())//checkifitmatches(and"generatethegroups")
{
System.out.println("*******REGEX2RESULT*******");//printswhateverthe.+?expressionmatched.
System.out.println(m.group(1));//printswhateverthe.+?expressionmatched.
System.out.println("*******REGEX2RESULT*******");//printswhateverthe.+?expressionmatched.
}String regexDate = "<b>Expiry Date:</b>(.+?)</td>";
Patternp=Pattern.compile(regexDate);
Matcherm=p.matcher(returnedHTML);
if(m.matches())//checkifitmatches(and"generatethegroups")
{
System.out.println("*******REGEXRESULT*******");
System.out.println(m.group(1));//printswhateverthe.+?expressionmatched.
System.out.println("*******REGEXRESULT*******");
}
2.
<string name="string_one">My string</string> <string name="string_two">Here it is: %s" </string>
String.format(getString(R.string.string_two), getString(R.string.string_one));