你要先写好正则表达式单纯判断用String的matches()方法就可以了public class Test {public static void main(String[] args) {String s = "1234";s.matches("\\d*");//\\d*为正则表达式,数字出现零次或多次,返回boolean类型}}

我想匹配 abcde,也就是一个*代表一个字符
在正则中*代表0个或者多个,因此此处的存储有问题,应该存储.或者_那么查询sql可以通过like和REGEXP 来实现
先替换成_然后在like 匹配
替换成.然后在匹配
按LS所说的确可以。要是一定要用String的话可以用 String[] s; for(String ss:s) if(ss.contains("贸易")) System.out.println(ss); 这样的方法。
import java.util.Random;public class Main { public static void main(String[] args) { char[] chs = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}; String str = new Main().getStr(chs); System.out.println(str); } public String getStr(char[] chs) { String str = ""; Random random = new Random(); for (int i = 0; i < 4; i++) { // 这种写法易于扩展,chs内容改了不用修改代码 str += chs[random.nextInt(chs.length)]; } str += random.nextInt(10); return str; }}