string判断字符串是否以什么结尾的正则表达式

2025-02-25 09:09:00
推荐回答(1个)
回答1:

提供下面的代码供参考:
import java.util.regex.*;

public class Regex {
public static void main(String[] args){
String sa = new String("abc123");
String sb = new String("abc123a");

Pattern pattern = Pattern.compile("\\d+$");
Matcher matcher = pattern.matcher(sa);