// System.out.println("--"+s);
public String replaceTokens(Pattern pattern, String userAgentString, String format)
	{
		// System.out.println("UserAgent: " + userAgentString);
		// System.out.println("Regexp: " + pattern.toString());
		// System.out.println("Replacement: " + format);
		Matcher m = pattern.matcher(userAgentString);	
		// Move the group content into an array
		List<String> groupContent = new ArrayList<String>();
		// System.out.println("Group Count: "+m.groupCount());
		m.find();
		for(int i=0; i<=m.groupCount(); i++)
		{
			String s = m.group(i);
			// System.out.println("--"+s);
			groupContent.add(s);
		}
		// Replace the tokens in the pattern 
		for(int i=0; i<groupContent.size(); i++)
		{
			String token = "#\\{\\$"+i+"\\}";
			// System.out.println("Replacing ["+token+"] with ["+groupContent.get(i)+"]");
			format = format.replaceAll(token, groupContent.get(i));
		}
		// System.out.println("Response: "+format);
		return format;
	}
{
String s = m.group(i);
// System.out.println("--"+s);
groupContent.add(s);
}
// System.out.println("Regexp: " + pattern.toString());
// System.out.println("Replacement: " + format);
Matcher m = pattern.matcher(userAgentString);
// Move the group content into an array
List<String> groupContent = new ArrayList<String>();
// System.out.println("Group Count: "+m.groupCount());
m.find();
for(int i=0; i<=m.groupCount(); i++)
{
String s = m.group(i);
// System.out.println("--"+s);
groupContent.add(s);
}
// Replace the tokens in the pattern
for(int i=0; i<groupContent.size(); i++)
{
String token = "#\\{\\$"+i+"\\}";
// System.out.println("Replacing ["+token+"] with ["+groupContent.get(i)+"]");
format = format.replaceAll(token, groupContent.get(i));
}
// System.out.println("Response: "+format);
public String replaceTokens(Pattern pattern, String userAgentString, String format)
{
// System.out.println("UserAgent: " + userAgentString);
// System.out.println("Regexp: " + pattern.toString());
// System.out.println("Replacement: " + format);
Matcher m = pattern.matcher(userAgentString);
// Move the group content into an array
List<String> groupContent = new ArrayList<String>();
// System.out.println("Group Count: "+m.groupCount());
m.find();
for(int i=0; i<=m.groupCount(); i++)
{
String s = m.group(i);
// System.out.println("--"+s);
groupContent.add(s);
}
// Replace the tokens in the pattern
for(int i=0; i<groupContent.size(); i++)
{
String token = "#\\{\\$"+i+"\\}";
// System.out.println("Replacing ["+token+"] with ["+groupContent.get(i)+"]");
format = format.replaceAll(token, groupContent.get(i));
}
// System.out.println("Response: "+format);
return format;
}