diff --git a/regexp.go b/regexp.go index a7ddbaf..800c425 100644 --- a/regexp.go +++ b/regexp.go @@ -240,6 +240,16 @@ func (re *Regexp) MatchString(s string) (bool, error) { return m != nil, nil } +// MatchStringSafe returns true if the string matches the regex. +// It ignores any errors and simply returns false if an error occurs. +func (re *Regexp) MatchStringSafe(s string) bool { + m, err := re.run(true, -1, getRunes(s)) + if err != nil { + return false + } + return m != nil +} + func (re *Regexp) getRunesAndStart(s string, startAt int) ([]rune, int) { if startAt < 0 { if re.RightToLeft() {