
uk.co.mruoc.string.transform.RegexStringTransformer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of string-utils Show documentation
Show all versions of string-utils Show documentation
Library containing string utilites
The newest version!
package uk.co.mruoc.string.transform;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import java.util.function.UnaryOperator;
import java.util.regex.Pattern;
@Slf4j
@RequiredArgsConstructor
public class RegexStringTransformer implements UnaryOperator {
private final Pattern pattern;
private final String replacement;
public RegexStringTransformer(String regex, String replacement) {
this(Pattern.compile(regex), replacement);
}
@Override
public String apply(String value) {
return pattern.matcher(value).replaceAll(replacement);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy