More actions

This commit is contained in:
Zachary Yedidia
2018-08-28 23:30:39 -04:00
parent de6ee879f4
commit d9b875f9df
6 changed files with 103 additions and 6 deletions

View File

@@ -139,6 +139,17 @@ func IsWordChar(r rune) bool {
return (r >= '0' && r <= '9') || (r >= 'A' && r <= 'Z') || (r >= 'a' && r <= 'z') || (r == '_')
}
// IsSpaces checks if a given string is only spaces
func IsSpaces(str []byte) bool {
for _, c := range str {
if c != ' ' {
return false
}
}
return true
}
// IsWhitespace returns true if the given rune is a space, tab, or newline
func IsWhitespace(c rune) bool {
return c == ' ' || c == '\t' || c == '\n'