编写程序,熟悉正则表达式
import java.util.regex.*; public class RegExp{ public static void main(String[] args){ System.out.println("32323232@qq.com".matches("[\\w[.-]]+@[\\w[.-]]+\\.\\w+")); System.out.println("a23544c".replaceAll("\\d","_")); Pattern p = Pattern.compile("-[a-z]{3}"); Matcher m = p.matcher("-agh-sfg-rgh"); System.out.println(m.matches() + " " + m.find() + " " + m.end() + " " + m.lookingAt() + " " + m.find() + " " + m.start()); System.out.println("a".matches("a*")); } }
浙公网安备 33010602011771号