Adapted the character matcher to the Java implementation