java 正则

将 1.0.0.apk 替换为 1.0.0.(1).apk

   public static void main(String[] args) {
        String version = "1.0.0.apk";
        String pattern = "(.*)(\\.([A-Za-z0-9])*)$";
        Pattern r = Pattern.compile(pattern);
        Matcher m = r.matcher(version);
        m.matches();
        String result = m.group(1) + ".(1)" + m.group(2);
    }

你可能感兴趣的:(java 正则)