Simple Email Regular Expression Judgment with Java

xiaoxiao2021-03-06  110

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.ready (); 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 ());}}}

转载请注明原文地址:https://www.9cbs.com/read-104760.html

New Post(0)