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 {
    /**********************************************************************/

    public static boolean containsAtLeastOne(String src, String[] strings) {
        // TODO: regex isn't good enough - doesn't work with the start or end of line
        src = src.toLowerCase();
        for (String s : strings) {
            Pattern p = Pattern.compile(".*[^a-z]" + s + "[^a-z].*");
            Matcher m = p.matcher(src);
            if (m.matches()) {
                return true;
            }
        }
        return false;
    }
}