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

master
Aadhavan Srinivasan 1 month ago
parent 1e0502c6aa
commit 992c5a9300

@ -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) {

Loading…
Cancel
Save