Tabnine Logo
String.matches
Code IndexAdd Tabnine to your IDE (free)

How to use
matches
method
in
java.lang.String

Best Java code snippets using java.lang.String.matches (Showing top 20 results out of 50,967)

origin: stackoverflow.com

 public static boolean isNumeric(String str)
{
 return str.matches("-?\\d+(\\.\\d+)?");  //match a number with optional '-' and decimal.
}
origin: spring-projects/spring-framework

public ServerInfo(String response, long responseTime) {
  this.responseTime = responseTime;
  this.webSocketEnabled = !response.matches(".*[\"']websocket[\"']\\s*:\\s*false.*");
}
origin: square/okhttp

private int retryAfter(Response userResponse, int defaultDelay) {
 String header = userResponse.header("Retry-After");
 if (header == null) {
  return defaultDelay;
 }
 // https://tools.ietf.org/html/rfc7231#section-7.1.3
 // currently ignores a HTTP-date, and assumes any non int 0 is a delay
 if (header.matches("\\d+")) {
  return Integer.valueOf(header);
 }
 return Integer.MAX_VALUE;
}
origin: spring-projects/spring-framework

@Override
public boolean match(String pattern, String path) {
  return path.matches(pattern);
}
origin: spring-projects/spring-framework

@Override
public boolean match(String pattern, String path) {
  return path.matches(pattern);
}
origin: google/guava

public void testToStringHelperLenient_localInnerClass() {
 class LocalInnerClass {}
 String toTest = MoreObjects.toStringHelper(new LocalInnerClass()).toString();
 assertTrue(toTest, toTest.matches(".*\\{\\}"));
}
origin: google/guava

public void testConstructorLenient_classObject() {
 String toTest = MoreObjects.toStringHelper(TestClass.class).toString();
 assertTrue(toTest, toTest.matches(".*\\{\\}"));
}
origin: google/guava

public void testConstructorLenient_instance() {
 String toTest = MoreObjects.toStringHelper(this).toString();
 assertTrue(toTest, toTest.matches(".*\\{\\}"));
}
origin: google/guava

public void testConstructorLenient_anonymousClass() {
 String toTest = MoreObjects.toStringHelper(new Object() {}).toString();
 assertTrue(toTest, toTest.matches(".*\\{\\}"));
}
origin: google/guava

public void testToStringHelperLenient_moreThanNineAnonymousClasses() {
 // The nth anonymous class has a name ending like "Outer.$n"
 Object o1 = new Object() {};
 Object o2 = new Object() {};
 Object o3 = new Object() {};
 Object o4 = new Object() {};
 Object o5 = new Object() {};
 Object o6 = new Object() {};
 Object o7 = new Object() {};
 Object o8 = new Object() {};
 Object o9 = new Object() {};
 Object o10 = new Object() {};
 String toTest = MoreObjects.toStringHelper(o10).toString();
 assertTrue(toTest, toTest.matches(".*\\{\\}"));
}
origin: google/guava

public void testToStringLenient_oneIntegerField() {
 String toTest =
   MoreObjects.toStringHelper(new TestClass()).add("field1", new Integer(42)).toString();
 assertTrue(toTest, toTest.matches(".*\\{field1\\=42\\}"));
}
origin: google/guava

public void testToStringLenient_nullInteger() {
 String toTest =
   MoreObjects.toStringHelper(new TestClass()).add("field1", (Integer) null).toString();
 assertTrue(toTest, toTest.matches(".*\\{field1\\=null\\}"));
}
origin: google/guava

public void testToStringLenient_oneField() {
 String toTest = MoreObjects.toStringHelper(new TestClass()).add("field1", "Hello").toString();
 assertTrue(toTest, toTest.matches(".*\\{field1\\=Hello\\}"));
}
origin: google/guava

public void testToStringLenient_addWithNullValue() {
 final String result = MoreObjects.toStringHelper(new TestClass()).add("Hello", null).toString();
 assertTrue(result, result.matches(".*\\{Hello\\=null\\}"));
}
origin: google/guava

public void testToStringHelperLenient_localInnerNestedClass() {
 class LocalInnerClass {
  class LocalInnerNestedClass {}
 }
 String toTest =
   MoreObjects.toStringHelper(new LocalInnerClass().new LocalInnerNestedClass()).toString();
 assertTrue(toTest, toTest.matches(".*\\{\\}"));
}
origin: spring-projects/spring-framework

/**
 * Match the primary value of the response header with a regex.
 * @param name the header name
 * @param pattern the regex pattern
 */
public WebTestClient.ResponseSpec valueMatches(String name, String pattern) {
  String value = getRequiredValue(name);
  String message = getMessage(name) + "=[" + value + "] does not match [" + pattern + "]";
  this.exchangeResult.assertWithDiagnostics(() -> AssertionErrors.assertTrue(message, value.matches(pattern)));
  return this.responseSpec;
}
origin: google/guava

public void testConstructorLenient_innerClass() {
 String toTest = MoreObjects.toStringHelper(new TestClass()).toString();
 assertTrue(toTest, toTest.matches(".*\\{\\}"));
}
origin: google/guava

public void testToStringLenient_addValue() {
 String toTest =
   MoreObjects.toStringHelper(new TestClass())
     .add("field1", 1)
     .addValue("value1")
     .add("field2", "value2")
     .addValue(2)
     .toString();
 final String expected = ".*\\{field1\\=1, value1, field2\\=value2, 2\\}";
 assertTrue(toTest, toTest.matches(expected));
}
origin: google/guava

public void testToStringLenient_addValueWithNullValue() {
 final String result =
   MoreObjects.toStringHelper(new TestClass())
     .addValue(null)
     .addValue("Hello")
     .addValue(null)
     .toString();
 final String expected = ".*\\{null, Hello, null\\}";
 assertTrue(result, result.matches(expected));
}
origin: spring-projects/spring-framework

@Override
public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) {
  if (!bdHolder.getBeanDefinition().isAutowireCandidate()) {
    return false;
  }
  if (!bdHolder.getBeanName().matches("[a-z-]+")) {
    return false;
  }
  if (bdHolder.getBeanDefinition().getAttribute("priority").equals("1")) {
    return true;
  }
  return false;
}
java.langStringmatches

Javadoc

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

An invocation of this method of the form str.matches(regex) yields exactly the same result as the expression

java.util.regex.Pattern. java.util.regex.Pattern#matches(String,CharSequence)(regex, str)

Popular methods of String

  • equals
  • length
    Returns the number of characters in this string.
  • substring
    Returns a string containing a subsequence of characters from this string. The returned string shares
  • startsWith
    Compares the specified string to this string, starting at the specified offset, to determine if the
  • format
    Returns a formatted string, using the supplied format and arguments, localized to the given locale.
  • split
    Splits this string using the supplied regularExpression. See Pattern#split(CharSequence,int) for an
  • trim
  • valueOf
    Creates a new string containing the specified characters in the character array. Modifying the chara
  • indexOf
  • endsWith
    Compares the specified string to this string to determine if the specified string is a suffix.
  • toLowerCase
    Converts this string to lower case, using the rules of locale.Most case mappings are unaffected by t
  • contains
    Determines if this String contains the sequence of characters in the CharSequence passed.
  • toLowerCase,
  • contains,
  • getBytes,
  • <init>,
  • equalsIgnoreCase,
  • replace,
  • isEmpty,
  • charAt,
  • hashCode,
  • lastIndexOf

Popular in Java

  • Reading from database using SQL prepared statement
  • setContentView (Activity)
  • requestLocationUpdates (LocationManager)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • String (java.lang)
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now