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;
	}
public String replaceTokens(Pattern pattern, String userAgentString, String format)
	{
	
	
	
		Matcher m = pattern.matcher(userAgentString);	
	
		List<String> groupContent = new ArrayList<String>();
	
		m.find();
		for(int i=0; i<=m.groupCount(); i++)
		{
			String s = m.group(i);
		
			groupContent.add(s);
		}
	
		for(int i=0; i<groupContent.size(); i++)
		{
			String token = "#\\{\\$"+i+"\\}";
		
			format = format.replaceAll(token, groupContent.get(i));
		}
	
		return format;
	}
public string replacetokens(pattern pattern, string useragentstring, string format) { matcher m = pattern.matcher(useragentstring); list<string> groupcontent = new arraylist<string>(); m.find(); for(int i=0; i<=m.groupcount(); i++) { string s = m.group(i); groupcontent.add(s); } for(int i=0; i<groupcontent.size(); i++) { string token = "#\\{\\$"+i+"\\}"; format = format.replaceall(token, groupcontent.get(i)); } return format; }