All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.mossol.bot.model.RegexText Maven / Gradle / Ivy

There is a newer version: 0.0.3.8
Show newest version
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