> For the complete documentation index, see [llms.txt](https://docs.elentra.org/ejs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.elentra.org/ejs/1.3/guide/routing/path-matching.md).

# Path Matching

## Introduction

Path matching is accomplished in EJS using the PathMatcher class. The PathMatcher class accepts a `RouteCollection` as the sole argument to its constructor, representing a routing tree to match against. The `match()` method accepts a string as the path to match, returning the matched `Route`object or null if a match isn't found.

The PathMatcher can be accessed directly via the `Router` using the `Router#match()` and `Router#getMatcher()` methods.

## **Class Synopsis**

```javascript
class PathMatcher
{
    constructor(RouteCollection routes);
    match(string path) : Route|null;
}
```
