@ -17,6 +17,8 @@ var NONCAPLPAREN_CHAR rune = 0xF0006 // Represents a non-capturing group's LPARE
var ESC_BACKSLASH rune = 0xF0007 // Represents an escaped backslash
var ESC_BACKSLASH rune = 0xF0007 // Represents an escaped backslash
var CHAR_RANGE rune = 0xF0008 // Represents a character range
var CHAR_RANGE rune = 0xF0008 // Represents a character range
var specialChars = [ ] rune { '?' , '*' , '\\' , '^' , '$' , '{' , '}' , '(' , ')' , '[' , ']' , '+' , '|' , '.' , '~' , '<' , '>' , LBRACKET , RBRACKET , NONCAPLPAREN_CHAR }
// An interface for int and rune, which are identical
// An interface for int and rune, which are identical
type character interface {
type character interface {
int | rune
int | rune
@ -32,9 +34,17 @@ func isWordBoundary(str []rune, idx int) bool {
return wbounded
return wbounded
}
}
func isSpecialChar ( c rune ) bool {
return slices . Contains ( specialChars , c )
}
// Some special characters have metacharacter replacements. These characters, when encountered in their literal form, can be treated as regular characters.
func isSpecialCharWithMetacharReplacement ( c rune ) bool {
return slices . Contains ( [ ] rune { '[' , ']' } , c )
}
func isNormalChar ( c rune ) bool {
func isNormalChar ( c rune ) bool {
specialChars := [ ] rune ( ` ?*\^$ { }()+|[].~<> ` )
specialChars = append ( specialChars , LBRACKET , RBRACKET , NONCAPLPAREN_CHAR )
return ! slices . Contains ( specialChars , c )
return ! slices . Contains ( specialChars , c )
}
}