List of usage examples for java.lang String matches
public boolean matches(String regex)
From source file:springfox.documentation.builders.PathSelectors.java
/** * Predicate that evaluates the supplied regular expression * * @param pathRegex - regex//from w w w . j a v a 2 s. com * @return predicate that matches a particular regex */ public static Predicate<String> regex(final String pathRegex) { return new Predicate<String>() { @Override public boolean apply(String input) { return input.matches(pathRegex); } }; }
From source file:com.kstenschke.shifter.models.shiftertypes.CssUnit.java
/** * @param str String to be checked * @return boolean Does the given string represents a CSS length value? */// ww w . j a v a2 s .c o m public static boolean isCssUnitValue(String str) { return (str.matches("[0-9]*(cm|em|in|pt|px)")); }
From source file:Main.java
/** * Generates valid component id from component name (see general comments in * class {@link ComponentIDUtil})// w w w . j a v a 2 s . c om * * @param compName * @return */ public static String generateIDFromName(String compName) { String alphaDigitsUnderscoreDashString = compName.replaceAll("[^a-zA-Z0-9\\-\\_]+", "_"); if (alphaDigitsUnderscoreDashString.matches("^[0-9].*")) { alphaDigitsUnderscoreDashString = "_" + alphaDigitsUnderscoreDashString; } return alphaDigitsUnderscoreDashString; }
From source file:Main.java
public static String getWifiIpv6() { try {/* ww w . ja v a 2 s .c o m*/ for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en .hasMoreElements();) { NetworkInterface intf = en.nextElement(); for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) { InetAddress inetAddress = enumIpAddr.nextElement(); if (!inetAddress.isLoopbackAddress() && inetAddress instanceof Inet6Address) { String[] ipv6 = inetAddress.getHostAddress().split("%"); String port = ipv6[1]; if (port.matches("wlan\\d+")) { return ipv6[0]; } } } } } catch (SocketException ex) { /*CONSUME*/ } return null; }
From source file:Main.java
public static boolean isCorrentLength(String str, int length) { String telRegex = "[0-9a-z]{" + length + "}"; return str == null ? false : str.matches(telRegex); }
From source file:MatchZipCodes.java
public static boolean isZipValid(String zip) { boolean retval = false; String zipCodePattern = "\\d{5}(-\\d{4})?"; retval = zip.matches(zipCodePattern); String msg = "NO MATCH: pattern:" + zip + "\r\n regex: " + zipCodePattern; if (retval) { msg = "MATCH : pattern:" + zip + "\r\n regex: " + zipCodePattern; }/*from w ww .j a v a2s .c o m*/ System.out.println(msg + "\r\n"); return retval; }
From source file:com.netflix.imfutility.conversion.templateParameter.TemplateParameter.java
public static boolean isTemplateParameter(String parameterString) { return parameterString.matches(TEMPLATE_PARAM_WITH_SUBPARAM); }
From source file:Main.java
public static Boolean isNumber(String str) { Boolean isNumber = false;/* ww w.j a v a 2s . c om*/ String expr = "^[0-9]+$"; if (str.matches(expr)) { isNumber = true; } return isNumber; }
From source file:de.olivergierke.whoops.customer.CustomerNumber.java
/** * Returns whether the given {@link String} is a valid {@link CustomerNumber}. * /*from w ww.j av a 2 s . c o m*/ * @param number * @return */ public static boolean isValid(String number) { return StringUtils.hasText(number) && number.matches(REGEX); }
From source file:Main.java
/** * Checks that string is a valid xml element name * //from w ww .j a va 2 s. c o m * Names can contain letters, numbers and other characters * Names cannot start with a number or punctuation character * Names cannot start with the letters xml (case insensitive) * Names cannot contain spaces * * @param name The string to check * @return True if valid */ public static boolean isValidElementOrAttribute(String name) { // Can't start with punctuation or a number if (!name.matches("^[a-zA-Z].*")) { return false; } // Can't start with xml (in any case) if (name.toLowerCase().startsWith("xml")) { return false; } // Can't contain spaces, ampersands, greater than or less than, fwd or back slash // semi-colon, asterisk, open and close (), open and close {}, open and close [] // plus sign, single quote, double quote, question mark, exclamation mark, back tick // tilde, at sign, dollar sign, percent sign, caret, equals, comma return !name.matches("^[a-zA-Z].*[\\s&<>/\\\\|;\\*\\(\\)\\{\\}\\[\\]\\+'\"\\?\\!`~@\\$\\%\\^=,].*"); }