Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    /**
     * Checking if a String matches desired Regex pattern. Used for validating
     * emails.
     */

    public static boolean isMatch(String text, String pattern) {
        try {
            Pattern patt = Pattern.compile(pattern);
            Matcher matcher = patt.matcher(text);
            return matcher.matches();
        } catch (RuntimeException e) {
            return false;
        }
    }
}