Example usage for java.lang String matches

List of usage examples for java.lang String matches

Introduction

In this page you can find the example usage for java.lang String matches.

Prototype

public boolean matches(String regex) 

Source Link

Document

Tells whether or not this string matches the given regular expression.

Usage

From source file:edu.umn.msi.tropix.proteomics.test.VerifyUtils.java

public static void verifyDTAList(final DTAList dtaList) {
    for (final DTAList.Entry entry : dtaList) {
        final byte[] bytes = entry.getContents();
        final LineIterator lineIterator = IOUtils.lineIterator(new StringReader(new String(bytes)));
        final String firstLine = lineIterator.nextLine();
        assert firstLine.matches("^\\d+\\.\\d+\\s+\\d+\\s*$");
        while (lineIterator.hasNext()) {
            final String line = lineIterator.nextLine();
            assert line.matches(RegexUtils.FLOATING_POINT_LITERAL + "\\s+" + RegexUtils.FLOATING_POINT_LITERAL
                    + "\\s*") : "Line is not of form -- <double> <double>";
        }//from   ww  w.  ja v  a 2  s  . co  m
        final String name = entry.getName();
        assert name.matches("^.*\\.\\d+\\.\\d+\\.\\d+\\.[dD][tT][aA]$");
    }
}

From source file:be.dnsbelgium.rdap.client.RDAPCLI.java

public static Type guessQueryType(String query) {
    try {//from w  w w. j a  v  a2 s .  c  o  m
        if (query.matches("^\\d+$")) {
            return Type.AUTNUM;
        }
        if (query.matches("^[\\d\\.:/]+$")) {
            return Type.IP;
        }
        if (DomainName.of(query).getLevelSize() > 1) {
            return Type.DOMAIN;
        }
        return Type.ENTITY;
    } catch (IllegalArgumentException iae) {
        LOGGER.debug("Not a domain name, defaulting to entity", iae);
        return Type.ENTITY;
    }
}

From source file:de.hsos.ecs.richwps.wpsmonitor.util.Validate.java

/**
 * Checks if the given string var is matched the given regex.
 * //from  w ww .  ja va2s  . c  om
 * @param var
 * @param regex
 * @return var
 */
public static String matchesRegex(final String var, final String regex) {
    if (!var.matches(regex)) {
        throw new IllegalArgumentException("The given String has not the right format.");
    }

    return var;
}

From source file:gov.wa.wsdot.cms.utils.Migration.java

/**
 * Match all files in directory which are not xml files.
 *///from w ww  .  j  av a2s  .c  om
public static void matchResources(String archiveFolder) {
    File files[] = (new File(archiveFolder)).listFiles(new FilenameFilter() {

        @Override
        public boolean accept(File archiveFolder, String name) {
            return name.matches(".*(?<!\\.xml)$");
        }
    });

    for (File file : files) {
        System.out.println("Found: " + file);
    }
}

From source file:net.itransformers.idiscover.v2.core.Main.java

public static String autolabel(String projectPath) {
    File networkPath = new File(projectPath, "network");

    if (!networkPath.exists()) {
        networkPath.mkdir();/*from w  ww  . j a v a 2  s. com*/

        File labelDir = new File(networkPath, "version1");
        labelDir.mkdir();
        return "network" + File.separator + "version1";
    }
    String[] fileList = new File(projectPath, "network").list();
    int max = 0;
    for (String fName : fileList) {
        if (fName.matches(VERSION_LABEL + "\\d+")) {
            int curr = Integer.parseInt(fName.substring(VERSION_LABEL.length()));
            if (max < curr)
                max = curr;
        }
    }
    return "network" + File.separator + VERSION_LABEL + (max + 1);
}

From source file:org.apache.cxf.dosgi.systests.common.AbstractDosgiSystemTest.java

protected static boolean isTimestamped(String version) {
    return version.matches(".+-\\d\\d\\d\\d\\d\\d\\d\\d\\.\\d\\d\\d\\d\\d\\d-\\d+");
}

From source file:edu.eurac.commul.pepperModules.mmax2.SaltExtendedFileGenerator.java

protected static String EscapeStringSimple(String original) throws MMAX2WrapperException {
    String copy = original + "";
    if (copy.matches(prohibed_regexp)) {
        throw new PepperModuleException("'" + copy + "' contains one of the following reserved @argument@ ("
                + prohibed_arguments + ")");
    }//from   w  ww  . ja va2  s  . c  o m
    return FileGenerator.EscapeStringSimple(copy);// if good at this level then check upstairs
}

From source file:Main.java

public static boolean isVehiclePlate(String plate) {
    String telRegex = "/^[\\u4e00-\\u9fa5]{1}[a-zA-Z]{1}[a-zA-Z_0-9]{5}$/";
    if (TextUtils.isEmpty(plate))
        return false;
    else/*from   w  w  w .  j a v  a  2s  .c  o m*/
        return plate.matches(telRegex);
}

From source file:com.salesmanager.core.util.CustomerUtil.java

public static boolean isValid(String regExp, String value) {
    if (value == null) {
        return false;
    }//w w w .j a va2  s.c om
    return value.matches(regExp);
}

From source file:Main.java

public static String insertSpace(String str) {
    String chr;
    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i < str.length(); i++) {
        chr = String.valueOf(str.charAt(i));
        if ((i > 0) && (chr.matches("[A-Z]")))
            buffer.append(" ");
        buffer.append(chr);//from  ww  w.  j a v a 2 s . c o  m
    }
    return buffer.toString();
}