Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions regexp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down