Online Java Compiler By
JavaTpoint.com
import java.util.regex.Matcher; import java.util.regex.Pattern; public class PatternCompileExample1 { public static void main(String[] args) { // TODO Auto-generated method stub //pattern/expression to be match Pattern p=Pattern.compile("@gmail"); //Regular expression Matcher m=p.matcher("abc@gmail.com"); if(m.find()) System.out.println(" Result : "+m); } }
Output