Package org.springframework.test.web.servlet.htmlunit

# Class UrlRegexRequestMatcher

java.lang.Object
org.springframework.test.web.servlet.htmlunit.UrlRegexRequestMatcher

All Implemented Interfaces:
  `WebRequestMatcher`

public final class UrlRegexRequestMatcher extends Object implements WebRequestMatcher
A `WebRequestMatcher` that allows matching on `WebRequest#getUrl().toExternalForm()` using a regular expression.

For example, if you would like to match on the domain `code.jquery.com`, you might want to use the following.

     WebRequestMatcher cdnMatcher = new UrlRegexRequestMatcher(".*?//code.jquery.com/.*");

Since:
  4.2
Author:
  Rob Winch, Sam Brannen
See Also:
  - `DelegatingWebConnection`

## Constructor Summary

Constructors
Constructor
Description
`UrlRegexRequestMatcher(String regex)`
`UrlRegexRequestMatcher(Pattern pattern)`

## Method Summary

Modifier and Type
Method
Description
`boolean`
`matches(org.htmlunit.WebRequest request)`
Whether this matcher matches on the supplied web request.

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

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

## Constructor Details

### UrlRegexRequestMatcher

public UrlRegexRequestMatcher(String regex)

### UrlRegexRequestMatcher

public UrlRegexRequestMatcher(Pattern pattern)

## Method Details

### matches

public boolean matches(org.htmlunit.WebRequest request)
Description copied from interface: `WebRequestMatcher`
Whether this matcher matches on the supplied web request.

Specified by:
  `matches` in interface `WebRequestMatcher`
Parameters:
  `request` - the `WebRequest` to attempt to match on
Returns:
  `true` if this matcher matches on the `WebRequest`