Sep 05
String s = "321";
boolean isNumber = s.matches("-?\\d+");

written by objects \\ tags: , ,

Sep 05
String s = "Some html escape codes ABC";
StringBuffer stringBuffer = new StringBuffer();
String re = "(?:&#(\\d+);)";
Pattern pattern = Pattern.compile(re);
Matcher matcher = pattern.matcher(args[0]);
while (matcher.find())
{
   char c = (char) Integer.parseInt(matcher.group(1));
   matcher.appendReplacement(stringBuffer, Character.toString(c));
}
matcher.appendTail(stringBuffer);
String result = stringBuffer.toString();

written by objects \\ tags: ,