| |
import java.sql.*; import java.io.*; import java.util.regex.*;
public class test{ public static void main(string[] args){ try{ string s = ""; while(!s.equals("q")){ system.out.print("input:"); datainputstream in = new datainputstream(new bufferedinputstream(system.in)); s = in.readline(); system.out.println("your input is :"+s); string check = "^([a-z0-9a-z]+[-|//.]?)+[a-z0-9a-z]@([a-z0-9a-z]+(-[a-z0-9a-z]+)?//.)+[a-za-z]{2,}$"; pattern regex = pattern.compile(check); matcher matcher = regex.matcher(s); boolean ismatched = matcher.matches(); if(ismatched){ system.out.println("it's a email"); }else{ system.out.println("it's not a email"); } } }catch(exception e){ system.out.println("error"+e.getmessage()); } } }
|
|