1/*
2 * Copyright (c) 2007 Mockito contributors
3 * This program is made available under the terms of the MIT License.
4 */
5
6package org.mockito.internal.matchers;
7
8import java.io.Serializable;
9import java.util.regex.Pattern;
10
11import org.mockito.ArgumentMatcher;
12
13public class Find implements ArgumentMatcher<String>, Serializable {
14
15    private final String regex;
16
17    public Find(String regex) {
18        this.regex = regex;
19    }
20
21    public boolean matches(String actual) {
22        return actual != null && Pattern.compile(regex).matcher(actual).find();
23    }
24
25    public String toString() {
26        return "find(\"" + regex.replaceAll("\\\\", "\\\\\\\\") + "\")";
27    }
28}
29