2 Commits

Author SHA1 Message Date
1bfb09b6c7 Made 'FindString' a method of 'Reg' 2025-01-30 22:51:31 -05:00
b0b8bf23af Updated documentation 2025-01-30 22:51:16 -05:00
3 changed files with 4 additions and 4 deletions

View File

@@ -86,7 +86,7 @@ Assertions:
# Flags
Flags are used to change the behavior of the engine. None of them are enabled by default. They are passed as an [ReFlag] slice to [Compile].
The list of flags, and their purpose, is provided in the type definition.
Flags are used to change the behavior of the engine. None of them are enabled by default. They are passed as variadic arguments to [Compile].
The list of flags is provided in the type definition for [ReFlag].
*/
package regex

View File

@@ -142,7 +142,7 @@ func pruneIndices(indices []Match) []Match {
// the regex, in the given string. The return value will be an empty string in two situations:
// 1. No match was found
// 2. The match was an empty string
func FindString(regex Reg, str string) string {
func (regex Reg) FindString(str string) string {
match, err := FindNthMatch(regex, str, 1)
if err != nil {
return ""

View File

@@ -704,7 +704,7 @@ func TestFindString(t *testing.T) {
panic(err)
}
} else {
foundString := FindString(regComp, test.str)
foundString := regComp.FindString(test.str)
if len(test.result) == 0 {
if foundString != "" {
t.Errorf("Expected no match got %v\n", foundString)