blob: d42f7d8a61c8f18109a6edd24b581fd0e9e120b0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package bjc.utils.parserutils.defines;
import java.util.function.UnaryOperator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* A simple match-and-replace operation on strings.
*
* @author EVE
*
*/
public class SimpleDefine implements UnaryOperator<String> {
private Pattern patt;
private String repl;
/**
* Create a new simple define.
*
* @param pattern
* The pattern to look for.
* @param replace
* The thing to replace it with.
*/
public SimpleDefine(Pattern pattern, String replace) {
patt = pattern;
repl = replace;
}
@Override
public String apply(String line) {
Matcher mat = patt.matcher(line);
return mat.replaceAll(repl);
}
}
|