net.mossol.bot.model.RegexText Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of line_bot_mossol-lib Show documentation
Show all versions of line_bot_mossol-lib Show documentation
Line Bot Mossol (line_bot_mossol-lib)
package net.mossol.bot.model;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Data
public class RegexText {
private String regex;
private TextType type;
private Pattern pattern;
private String response;
public RegexText compilePattern() {
pattern = Pattern.compile(regex);
return this;
}
public List match(String message) {
Matcher matcher = pattern.matcher(message);
List results = new ArrayList<>();
while (matcher.find()) {
results.add(matcher.group());
}
return results;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy