Java正则表达式

校验占位符

 // 获取单元格文本
                    String cellText = cell.getText();

                    // 使用正则表达式匹配占位符
                    String pattern = "\\$\\{([^\\}]+)\\}";
                    Pattern placeholderPattern = Pattern.compile(pattern);
                    Matcher matcher = placeholderPattern.matcher(cellText);

                    // 清空单元格内容
                    cell.setText("");

                    // 替换占位符内容
                    while (matcher.find()) {
                    如果符合就进入这里
                    }

去除0.0小数点的.0

Pattern pattern = Pattern.compile("(\\d+)\\.0");
Matcher matcher = pattern.matcher(input);
                StringBuffer output = new StringBuffer();
                while (matcher.find()) {
                    matcher.appendReplacement(output, matcher.group(1));
                }
                matcher.appendTail(output);
                map3.put("cur_" + key, output.toString());

你可能感兴趣的:(java,正则表达式,javascript)