Made conditions for word boundary a little more relaxed

master
Aadhavan Srinivasan 2 months ago
parent a19d409796
commit 19dc5064c8

@ -24,7 +24,7 @@ func dotChars() []rune { // Returns all possible characters represented by the d
// Returns true if str[idx] and str[idx-1] are separated by a word boundary. // Returns true if str[idx] and str[idx-1] are separated by a word boundary.
func isWordBoundary(str []rune, idx int) bool { func isWordBoundary(str []rune, idx int) bool {
wbounded := idx == 0 || wbounded := idx == 0 ||
idx == len(str)-1 || idx >= len(str)-1 ||
(!slices.Contains(wordChars, str[idx-1]) && slices.Contains(wordChars, str[idx])) || (!slices.Contains(wordChars, str[idx-1]) && slices.Contains(wordChars, str[idx])) ||
(slices.Contains(wordChars, str[idx-1]) && !slices.Contains(wordChars, str[idx])) (slices.Contains(wordChars, str[idx-1]) && !slices.Contains(wordChars, str[idx]))
return wbounded return wbounded

Loading…
Cancel
Save