CommonRegex port for Java