regex \s in java code example

Example 1: regular expression java

//Ther are three type of REGULAR EXPRESSION     
   //first
   ^(.+)@(.+)$   "^(.+)@(.+)$\""
   //second
   ^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$
     //third
   ^[\\w!#$%&'*+/=?`{|}~^-]+(?:\\.[\\w!#$%&'*+/=?`{|}~^-]+)*@(?!-)(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}$

Example 2: regex java

import java.io.*;
import java.util.regex.*;

public class testRegex {

    private static Pattern pattern;
    private static Matcher matcher;

    public static void main(String args[]) {
        pattern = Pattern.compile("Hugo");
        matcher = pattern.matcher("Hugo Etiévant");
        while(matcher.find()) {
            System.out.println("Trouvé !");
        }
    }
}

Tags:

Java Example