#[no_std, cache_output]
type @regex

impl @regex {
    new: #[desc("Create a new instance of regex")]
    (#[desc("A regex string. Make sure to use two backslashes to escape selectors instead of one or it will error")] re: @string) {
        return {
            type: @regex,
            regex: re
        }
    },
    match: #[desc("Checks if the regex matches a string argument")]
    (self, match: @string) {
        return $.regex(self.regex, match, "match", null)
    },
    replace: #[desc("Regex replace the contents of a string")]
    (self, to_replace: @string, replacer: @string) {
        let t_rep = to_replace;
        return $.regex(self.regex, t_rep, "replace", replacer)
    },
    findall: #[desc("Regex find all matche indices of the string argument")]
    (self, match: @string) {
        return $.regex(self.regex, match, "findall", null)
    }
}