Replaced isAlphaNum() with isNormalChar(), which returns true if the character isn't special (also returns true for unicode characters, which the previous function didn't
This commit is contained in:
7
misc.go
7
misc.go
@@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"slices"
|
"slices"
|
||||||
"unicode"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var whitespaceChars = []rune{' ', '\t', '\n'}
|
var whitespaceChars = []rune{' ', '\t', '\n'}
|
||||||
@@ -33,8 +32,10 @@ func isWordBoundary(str []rune, idx int) bool {
|
|||||||
return wbounded
|
return wbounded
|
||||||
}
|
}
|
||||||
|
|
||||||
func isAlphaNum(c rune) bool {
|
func isNormalChar(c rune) bool {
|
||||||
return unicode.IsLetter(c) || unicode.IsNumber(c)
|
specialChars := []rune(`?*\^${}()+|[].~`)
|
||||||
|
specialChars = append(specialChars, LBRACKET, RBRACKET)
|
||||||
|
return !slices.Contains(specialChars, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func assert(cond bool) {
|
func assert(cond bool) {
|
||||||
|
Reference in New Issue
Block a user