正则表达式匹配全角空格

package test.regex; import java.util.regex.Matcher; import java.util.regex.Pattern; public class SbcBlankRegexTest { final static String regex = "///*1//*/[//s|/u3000]*"; final static String regex2 = "[//s|/u3000]+"; static Pattern p = Pattern.compile(regex); public void test() { String s = "insert /*1*/  into x x x"; test(s); s = "insert/*1*/into/*1*/ xxx"; test(s); } private void test(String s) { Matcher matcher = p.matcher(s); while (matcher.find()) { System.out.println(s.substring(matcher.start())); } } private void buildPattern(String regex){ p = Pattern.compile(regex); } /** * @param args */ public static void main(String[] args) { SbcBlankRegexTest t = new SbcBlankRegexTest(); t.buildPattern(regex2); t.test(); } }

你可能感兴趣的:(正则表达式,regex,string,insert,class)