diff options
Diffstat (limited to 'src/utils/twtstr.nim')
-rw-r--r-- | src/utils/twtstr.nim | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim index 28a91558..13a432bf 100644 --- a/src/utils/twtstr.nim +++ b/src/utils/twtstr.nim @@ -177,6 +177,20 @@ func toHexLower*(u: uint16): string = func equalsIgnoreCase*(s1, s2: string): bool {.inline.} = return s1.cmpIgnoreCase(s2) == 0 +func startsWithIgnoreCase*(s1, s2: string): bool = + if s1.len < s2.len: return false + for i in 0 ..< s2.len: + if s1[i].toLowerAscii() != s2[i].toLowerAscii(): + return false + return true + +func endsWithIgnoreCase*(s1, s2: string): bool = + if s1.len < s2.len: return false + for i in countdown(s2.high, 0): + if s1[i].toLowerAscii() != s2[i].toLowerAscii(): + return false + return true + func isDigitAscii*(r: Rune): bool = return int(r) < 256 and isDigit(char(r)) |