Reported by: Ben Hoyt (GoAWK integration testing)
Source: benhoyt/goawk#264 (comment)
Problem
The ^ anchor (start of line/string) is not working correctly in MatchString(). Patterns with ^ are matching even when the pattern doesn't match from the beginning.
Test Cases
Test 1: ^.$ should match ONLY single-character strings
re := coregex.Compile(`^.$`)
re.MatchString("1") // ✅ true (correct)
re.MatchString("22") // ❌ true (WRONG - should be false)
re.MatchString("333") // ❌ true (WRONG - should be false)
Test 2: ^[a-z]+$ should match ONLY alphabetic strings
re := coregex.Compile(`^[a-z]+$`)
re.MatchString("abc") // ✅ true (correct)
re.MatchString("a68") // ❌ true (WRONG - should be false, contains digits)
re.MatchString("123") // ✅ false (correct)
Expected Behavior
Patterns with ^ should only match when the pattern starts at the beginning of the string.
Impact
Related Issues
Reported by: Ben Hoyt (GoAWK integration testing)
Source: benhoyt/goawk#264 (comment)
Problem
The
^anchor (start of line/string) is not working correctly inMatchString(). Patterns with^are matching even when the pattern doesn't match from the beginning.Test Cases
Test 1:
^.$should match ONLY single-character stringsTest 2:
^[a-z]+$should match ONLY alphabetic stringsExpected Behavior
Patterns with
^should only match when the pattern starts at the beginning of the string.Impact
^anchorRelated Issues