public class Main {
public static void main(String[] args) {
// Prepare a regular expression to represent a pattern
/* from
N o w J a v a . c o m*/
String regex = ".@.";
// Try matching many strings against the regular expression
Main.matchIt("a@k", regex);
Main.matchIt("webmaster@mypkg.com", regex);
Main.matchIt("r@j", regex);
Main.matchIt("a%N", regex);
Main.matchIt(".@.", regex);
}
public static void matchIt(String str, String regex) {
// Test for pattern match
/** from
n o w j a v a . c o m - 时 代 Java**/
if (str.matches(regex)) {
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。