This repository has been archived by the owner on Feb 13, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add IsAny method for matchers package
- Loading branch information
1 parent
667c814
commit 6c76619
Showing
5 changed files
with
33 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package matchers | ||
|
||
import ( | ||
"regexp" | ||
"strings" | ||
|
||
"github.com/sahilm/fuzzy" | ||
) | ||
|
||
func IsAny(substr string, s string) bool { | ||
if strings.Index(s, substr) > 0 { | ||
return false | ||
} | ||
|
||
return true | ||
} | ||
|
||
func IsMatch(pattern string, s string) bool { | ||
defer func() { | ||
_ = recover() | ||
}() | ||
|
||
re := regexp.MustCompile(pattern) | ||
return re.FindString(s) != "" | ||
} | ||
|
||
func IsMatchFuzz(pattern string, s []string) bool { | ||
matches := fuzzy.Find(pattern, s) | ||
|
||
return len(matches) > 0 | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters