Codota Logo
Pattern.matcher
Code IndexAdd Codota to your IDE (free)

How to use
matcher
method
in
java.util.regex.Pattern

Best Java code snippets using java.util.regex.Pattern.matcher (Showing top 20 results out of 120,573)

Refine searchRefine arrow

  • Matcher.group
  • Matcher.find
  • Pattern.compile
  • Matcher.matches
  • PrintStream.println
  • Common ways to obtain Pattern
private void myMethod () {
Pattern p =
  • Codota IconString regex;Pattern.compile(regex)
  • Codota IconString regex;Pattern.compile(regex, flags)
  • Codota IconStringBuffer regex;Pattern.compile(regex.toString())
  • Smart code suggestions by Codota
}
origin: spring-projects/spring-framework

/**
 * Returns {@code true} if the exclusion {@link Pattern} at index {@code patternIndex}
 * matches the supplied candidate {@code String}.
 */
@Override
protected boolean matchesExclusion(String candidate, int patternIndex) {
  Matcher matcher = this.compiledExclusionPatterns[patternIndex].matcher(candidate);
  return matcher.matches();
}
origin: square/retrofit

/**
 * Gets the set of unique path parameters used in the given URI. If a parameter is used twice
 * in the URI, it will only show up once in the set.
 */
static Set<String> parsePathParameters(String path) {
 Matcher m = PARAM_URL_REGEX.matcher(path);
 Set<String> patterns = new LinkedHashSet<>();
 while (m.find()) {
  patterns.add(m.group(1));
 }
 return patterns;
}
origin: stackoverflow.com

 String mydata = "some string with 'the data i want' inside";
Pattern pattern = Pattern.compile("'(.*?)'");
Matcher matcher = pattern.matcher(mydata);
if (matcher.find())
{
  System.out.println(matcher.group(1));
}
origin: apache/kafka

/**
 * Extracts the hostname from a "host:port" address string.
 * @param address address string to parse
 * @return hostname or null if the given address is incorrect
 */
public static String getHost(String address) {
  Matcher matcher = HOST_PORT_PATTERN.matcher(address);
  return matcher.matches() ? matcher.group(1) : null;
}
origin: org.mockito/mockito-core

static boolean isJava8BelowUpdate45(String jvmVersion) {
  Matcher matcher = JAVA_8_RELEASE_VERSION_SCHEME.matcher(jvmVersion);
  if (matcher.matches()) {
    int update = Integer.parseInt(matcher.group(1));
    return update < 45;
  }
  matcher = JAVA_8_DEV_VERSION_SCHEME.matcher(jvmVersion);
  if (matcher.matches()) {
    int update = Integer.parseInt(matcher.group(1));
    return update < 45;
  }
  matcher = Pattern.compile("1\\.8\\.0-b\\d+").matcher(jvmVersion);
  return matcher.matches();
}
origin: jenkinsci/jenkins

/**
 * See {@link hudson.FilePath#isAbsolute(String)}.
 * @param path String representing <code> Platform Specific </code> (unlike FilePath, which may get Platform agnostic paths), may not be null
 * @return true if String represents absolute path on this platform, false otherwise
 */
public static boolean isAbsolute(String path) {
  Pattern DRIVE_PATTERN = Pattern.compile("[A-Za-z]:[\\\\/].*");
  return path.startsWith("/") || DRIVE_PATTERN.matcher(path).matches();
}
origin: spring-projects/spring-framework

private void assertDescriptionContainsExpectedPath(ClassPathResource resource, String expectedPath) {
  Matcher matcher = DESCRIPTION_PATTERN.matcher(resource.getDescription());
  assertTrue(matcher.matches());
  assertEquals(1, matcher.groupCount());
  String match = matcher.group(1);
  assertEquals(expectedPath, match);
}
origin: google/guava

/**
 * Returns a new {@code MatchResult} that corresponds to a successful match. Apache Harmony (used
 * in Android) requires a successful match in order to generate a {@code MatchResult}:
 * http://goo.gl/5VQFmC
 */
private static MatchResult newMatchResult() {
 Matcher matcher = Pattern.compile(".").matcher("X");
 matcher.find();
 return matcher.toMatchResult();
}
origin: stackoverflow.com

 Pattern p = Pattern.compile("^[a-zA-Z]+([0-9]+).*");
Matcher m = p.matcher("Testing123Testing");

if (m.find()) {
  System.out.println(m.group(1));
}
origin: apache/kafka

/**
 * Extracts the port number from a "host:port" address string.
 * @param address address string to parse
 * @return port number or null if the given address is incorrect
 */
public static Integer getPort(String address) {
  Matcher matcher = HOST_PORT_PATTERN.matcher(address);
  return matcher.matches() ? Integer.parseInt(matcher.group(2)) : null;
}
origin: spring-projects/spring-framework

/**
 * Returns {@code true} if the {@link Pattern} at index {@code patternIndex}
 * matches the supplied candidate {@code String}.
 */
@Override
protected boolean matches(String pattern, int patternIndex) {
  Matcher matcher = this.compiledPatterns[patternIndex].matcher(pattern);
  return matcher.matches();
}
origin: Netflix/eureka

  private static String resolveJarUrl(Class<?> clazz) {
    URL location = clazz.getResource('/' + clazz.getName().replace('.', '/') + ".class");
    if (location != null) {
      Matcher matcher = Pattern.compile("(jar:file.*-[\\d.]+(-rc[\\d]+|-SNAPSHOT)?.jar)!.*$").matcher(location.toString());
      if (matcher.matches()) {
        return matcher.group(1);
      }
    }
    return null;
  }
}
origin: spring-projects/spring-framework

@Override
public String extractVersion(String requestPath) {
  Matcher matcher = pattern.matcher(requestPath);
  if (matcher.find()) {
    String match = matcher.group(1);
    return (match.contains("-") ? match.substring(match.lastIndexOf('-') + 1) : match);
  }
  else {
    return null;
  }
}
origin: libgdx/libgdx

/**
 * @return {@code true} if application runs on a mobile device
 */
public static boolean isMobileDevice() {
  // RegEx pattern from detectmobilebrowsers.com (public domain)
  String pattern = "(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec" +
      "|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)" +
      "i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)" +
      "|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk";
  Pattern p = Pattern.compile(pattern);
  Matcher m = p.matcher(Window.Navigator.getUserAgent().toLowerCase());
  return m.matches();
}
origin: google/guava

 private static void assertContainsRegex(String expectedRegex, String actual) {
  Pattern pattern = Pattern.compile(expectedRegex);
  Matcher matcher = pattern.matcher(actual);
  if (!matcher.find()) {
   String actualDesc = (actual == null) ? "null" : ('<' + actual + '>');
   fail("expected to contain regex:<" + expectedRegex + "> but was:" + actualDesc);
  }
 }
}
origin: libgdx/libgdx

private String getError (String line) {
  Pattern pattern = Pattern.compile(":[0-9]+:[0-9]+:(.+)");
  Matcher matcher = pattern.matcher(line);
  matcher.find();
  return matcher.groupCount() >= 1 ? matcher.group(1).trim() : null;
}
origin: Netflix/eureka

public static String extractZoneFromHostName(String hostName) {
  Matcher matcher = ZONE_RE.matcher(hostName);
  if (matcher.matches()) {
    return matcher.group(2);
  }
  return null;
}
origin: square/okhttp

/** Returns true if {@code host} is not a host name and might be an IP address. */
public static boolean verifyAsIpAddress(String host) {
 return VERIFY_AS_IP_ADDRESS.matcher(host).matches();
}
origin: Netflix/eureka

private void handleInstanceGET(HttpExchange httpExchange) throws IOException {
  Matcher matcher = Pattern.compile("/v2/instances/([^/]+)").matcher(httpExchange.getRequestURI().getPath());
  if (matcher.matches()) {
    mapResponse(httpExchange, requestHandler.getInstance(matcher.group(1)));
  } else {
    httpExchange.sendResponseHeaders(HttpServletResponse.SC_NOT_FOUND, 0);
  }
}
origin: spring-projects/spring-framework

@Override
@Nullable
public String extractVersion(String requestPath) {
  Matcher matcher = pattern.matcher(requestPath);
  if (matcher.find()) {
    String match = matcher.group(1);
    return (match.contains("-") ? match.substring(match.lastIndexOf('-') + 1) : match);
  }
  else {
    return null;
  }
}
java.util.regexPatternmatcher

Javadoc

Returns a Matcher for this pattern applied to the given input. The Matcher can be used to match the Pattern against the whole input, find occurrences of the Pattern in the input, or replace parts of the input.

Popular methods of Pattern

  • compile
  • quote
    Returns a literal pattern String for the specifiedString.This method produces a String that can be u
  • split
    Splits the given input sequence around matches of this pattern. The array returned by this method co
  • pattern
  • matches
  • toString
    Returns the string representation of this pattern. This is the regular expression from which this pa
  • flags
    Returns this pattern's match flags.
  • splitAsStream
  • asPredicate
  • <init>
    This private constructor is used to create all Patterns. The pattern string and match flags are all
  • closeImpl
  • compileImpl
  • closeImpl,
  • compileImpl,
  • closure,
  • error,
  • escape,
  • RemoveQEQuoting,
  • accept,
  • addFlag,
  • append

Popular in Java

  • Reading from database using SQL prepared statement
  • compareTo (BigDecimal)
  • getSystemService (Context)
  • getSharedPreferences (Context)
  • PrintStream (java.io)
    A PrintStream adds functionality to another output stream, namely the ability to print representatio
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Hashtable (java.util)
    Hashtable is a synchronized implementation of Map. All optional operations are supported.Neither key
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Table (org.hibernate.mapping)
    A relational table
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now