1.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">?
<html xmlns="http://www.w3.org/1999/xhtml">?
<head>?
<body>?
?
<table cellpadding="2" cellspacing="0" border="0" width="100%" class="light_box">?
<tr>?
<td valign=top><b>Expiry Date:</b> 11 May 2010</td>?
?
<td align=right><b>Current Period:</b> Ends: 11 May 2010?
</td></tr>?
<tr>?
<td colspan=2> </td>?
</tr></table>?
</body>?
</html>?
String regexDate = "<b>Expiry Date:</b>(.+?)</td>";?
// ? ? ? ? ?String regexDate = "<b>Expiry Date:<\\/b>";?
? ? ? ? ? ? Pattern p = Pattern.compile(regexDate);?
? ? ? ? ? ? String[] items = p.split(returnedHTML);?
? ? ? ? ? ? System.out.println("*******REGEX 1 RESULT*******"); // prints whatever the .+? expression matched.?
? ? ? ? ? ? for(String s : items) ?
? ? ? ? ? ? { ?
? ? ? ? ? ? ? ? System.out.println(s); ?
? ? ? ? ? ? }?
? ? ? ? ? ? System.out.println("*******REGEX 1 RESULT*******"); // prints whatever the .+? expression matched.?
?
? ? ? ? ? ? Pattern p2 = Pattern.compile("<b>Expiry Date:<\\/b>");?
? ? ? ? ? ? Matcher m = p2.matcher(returnedHTML);?
?
? ? ? ? ? ? if (m.matches()) // check if it matches (and "generate the groups")?
? ? ? ? ? ? {?
? ? ? ? ? ? ? ? System.out.println("*******REGEX 2 RESULT*******"); // prints whatever the .+? expression matched.?
? ? ? ? ? ? ? ? System.out.println(m.group(1)); // prints whatever the .+? expression matched.?
? ? ? ? ? ? ? ? System.out.println("*******REGEX 2 RESULT*******"); // prints whatever the .+? expression matched.?
? ? ? ? ? ? }?
String regexDate = "<b>Expiry Date:</b>(.+?)</td>";?
Pattern p = Pattern.compile(regexDate);?
Matcher m = p.matcher(returnedHTML);?
?
if (m.matches()) // check if it matches (and "generate the groups")?
{?
? System.out.println("*******REGEX RESULT*******"); ?
? System.out.println(m.group(1)); // prints whatever the .+? expression matched.?
? System.out.println("*******REGEX RESULT*******"); ?
}?
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));?