1.在javascript中:

var str=‘int year = 2018;System.out.println(year + "不是闰年")';
str.match(/[a-zA-Z]+/ig);
//结果["int", "year", "System", "out", "println","year "]

2.在java中:

Pattern p = Pattern.compile("[a-zA-Z]+");
Matcher m = p.matcher(keywords[i].trim());
while (m.find()) {
    System.out.println(m.group() + "   位置:[" + m.start() + "," + m.end() + "]");
}

相关文章:

  • 2021-11-17
  • 2021-07-21
  • 2021-05-27
  • 2021-06-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2021-11-17
  • 2021-11-17
  • 2021-11-17
相关资源
相似解决方案