Added support for non-capturing groups
This commit is contained in:
3
misc.go
3
misc.go
@@ -13,6 +13,7 @@ var RBRACKET rune = 0xF0001
|
||||
var ANY_CHAR rune = 0xF0002 // Represents any character - used for states where the allChars flag is on.
|
||||
var LPAREN_CHAR rune = 0xF0003 // Parentheses in regex are concatenated with this - it acts as a pseudio-parentheses
|
||||
var RPAREN_CHAR rune = 0xF0004
|
||||
var NONCAPLPAREN_CHAR rune = 0xF0005 // Represents a non-capturing group's LPAREN
|
||||
|
||||
// Returns true if str[idx] and str[idx-1] are separated by a word boundary.
|
||||
func isWordBoundary(str []rune, idx int) bool {
|
||||
@@ -26,7 +27,7 @@ func isWordBoundary(str []rune, idx int) bool {
|
||||
|
||||
func isNormalChar(c rune) bool {
|
||||
specialChars := []rune(`?*\^${}()+|[].~<>`)
|
||||
specialChars = append(specialChars, LBRACKET, RBRACKET)
|
||||
specialChars = append(specialChars, LBRACKET, RBRACKET, NONCAPLPAREN_CHAR)
|
||||
return !slices.Contains(specialChars, c)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user