Package org.springframework.util

# Class PatternMatchUtils

java.lang.Object
org.springframework.util.PatternMatchUtils

public abstract class PatternMatchUtils extends Object
Utility methods for simple pattern matching, in particular for Spring's typical `xxx*`, `*xxx`, `*xxx*`, and `xxx*yyy` pattern styles.

Since:
  2.0
Author:
  Juergen Hoeller

## Constructor Summary

Constructors
Constructor
Description
`PatternMatchUtils()`

## Method Summary

Modifier and Type
Method
Description
`static boolean`
`simpleMatch(String[] patterns, String str)`
Match a String against the given patterns, supporting direct equality as well as the following simple pattern styles: `xxx*`, `*xxx`, `*xxx*`, and `xxx*yyy` (with an arbitrary number of pattern parts).
`static boolean`
`simpleMatch(String pattern, String str)`
Match a String against the given pattern, supporting direct equality as well as the following simple pattern styles: `xxx*`, `*xxx`, `*xxx*`, and `xxx*yyy` (with an arbitrary number of pattern parts).
`static boolean`
`simpleMatchIgnoreCase(String[] patterns, String str)`
Variant of `simpleMatch(String[], String)` that ignores upper/lower case.
`static boolean`
`simpleMatchIgnoreCase(String pattern, String str)`
Variant of `simpleMatch(String, String)` that ignores upper/lower case.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### PatternMatchUtils

public PatternMatchUtils()

## Method Details

### simpleMatch

public static boolean simpleMatch(@Nullable String pattern, @Nullable String str)
Match a String against the given pattern, supporting direct equality as well as the following simple pattern styles: `xxx*`, `*xxx`, `*xxx*`, and `xxx*yyy` (with an arbitrary number of pattern parts).

Returns `false` if the supplied String or pattern is `null`.

Parameters:
  `pattern` - the pattern to match against
  `str` - the String to match
Returns:
  whether the String matches the given pattern

### simpleMatchIgnoreCase

public static boolean simpleMatchIgnoreCase(@Nullable String pattern, @Nullable String str)
Variant of `simpleMatch(String, String)` that ignores upper/lower case.

Since:
  6.1.20

### simpleMatch

public static boolean simpleMatch(@Nullable String[] patterns, @Nullable String str)
Match a String against the given patterns, supporting direct equality as well as the following simple pattern styles: `xxx*`, `*xxx`, `*xxx*`, and `xxx*yyy` (with an arbitrary number of pattern parts).

Returns `false` if the supplied String is `null` or if the supplied patterns array is `null` or empty.

Parameters:
  `patterns` - the patterns to match against
  `str` - the String to match
Returns:
  whether the String matches any of the given patterns

### simpleMatchIgnoreCase

public static boolean simpleMatchIgnoreCase(@Nullable String[] patterns, @Nullable String str)
Variant of `simpleMatch(String[], String)` that ignores upper/lower case.

Since:
  6.1.20