public static void main(String[] args) {
    
    Pattern pattern =null;
    String content = "30.年前";
    if(content.contains(".")){
        pattern = Pattern.compile("^(\\d+.{0,1})(.*)");
    }else{
         pattern = Pattern.compile("^(\\d+)(.*)");
    }
    Matcher matchers = pattern.matcher(content);
    if (matchers.matches()) {//数字开头
        //System.out.println(matchers.group(1));// =30
        //System.out.println(matchers.group(2));// =年前
    }
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2021-07-28
相关资源
相似解决方案