cleaned up strutils.nim
This commit is contained in:
parent
5e93eb9d7a
commit
653dcb8027
1 changed files with 13 additions and 17 deletions
|
|
@ -32,10 +32,6 @@ when defined(nimOldSplit):
|
||||||
else:
|
else:
|
||||||
{.pragma: deprecatedSplit.}
|
{.pragma: deprecatedSplit.}
|
||||||
|
|
||||||
type
|
|
||||||
CharSet* {.deprecated.} = set[char] # for compatibility with Nim
|
|
||||||
{.deprecated: [TCharSet: CharSet].}
|
|
||||||
|
|
||||||
const
|
const
|
||||||
Whitespace* = {' ', '\t', '\v', '\r', '\l', '\f'}
|
Whitespace* = {' ', '\t', '\v', '\r', '\l', '\f'}
|
||||||
## All the characters that count as whitespace.
|
## All the characters that count as whitespace.
|
||||||
|
|
@ -78,40 +74,40 @@ proc isAlphaAscii*(c: char): bool {.noSideEffect, procvar,
|
||||||
return c in Letters
|
return c in Letters
|
||||||
|
|
||||||
proc isAlphaNumeric*(c: char): bool {.noSideEffect, procvar,
|
proc isAlphaNumeric*(c: char): bool {.noSideEffect, procvar,
|
||||||
rtl, extern: "nsuIsAlphaNumericChar".}=
|
rtl, extern: "nsuIsAlphaNumericChar".} =
|
||||||
## Checks whether or not `c` is alphanumeric.
|
## Checks whether or not `c` is alphanumeric.
|
||||||
##
|
##
|
||||||
## This checks a-z, A-Z, 0-9 ASCII characters only.
|
## This checks a-z, A-Z, 0-9 ASCII characters only.
|
||||||
return c in Letters or c in Digits
|
return c in Letters+Digits
|
||||||
|
|
||||||
proc isDigit*(c: char): bool {.noSideEffect, procvar,
|
proc isDigit*(c: char): bool {.noSideEffect, procvar,
|
||||||
rtl, extern: "nsuIsDigitChar".}=
|
rtl, extern: "nsuIsDigitChar".} =
|
||||||
## Checks whether or not `c` is a number.
|
## Checks whether or not `c` is a number.
|
||||||
##
|
##
|
||||||
## This checks 0-9 ASCII characters only.
|
## This checks 0-9 ASCII characters only.
|
||||||
return c in Digits
|
return c in Digits
|
||||||
|
|
||||||
proc isSpaceAscii*(c: char): bool {.noSideEffect, procvar,
|
proc isSpaceAscii*(c: char): bool {.noSideEffect, procvar,
|
||||||
rtl, extern: "nsuIsSpaceAsciiChar".}=
|
rtl, extern: "nsuIsSpaceAsciiChar".} =
|
||||||
## Checks whether or not `c` is a whitespace character.
|
## Checks whether or not `c` is a whitespace character.
|
||||||
return c in Whitespace
|
return c in Whitespace
|
||||||
|
|
||||||
proc isLowerAscii*(c: char): bool {.noSideEffect, procvar,
|
proc isLowerAscii*(c: char): bool {.noSideEffect, procvar,
|
||||||
rtl, extern: "nsuIsLowerAsciiChar".}=
|
rtl, extern: "nsuIsLowerAsciiChar".} =
|
||||||
## Checks whether or not `c` is a lower case character.
|
## Checks whether or not `c` is a lower case character.
|
||||||
##
|
##
|
||||||
## This checks ASCII characters only.
|
## This checks ASCII characters only.
|
||||||
return c in {'a'..'z'}
|
return c in {'a'..'z'}
|
||||||
|
|
||||||
proc isUpperAscii*(c: char): bool {.noSideEffect, procvar,
|
proc isUpperAscii*(c: char): bool {.noSideEffect, procvar,
|
||||||
rtl, extern: "nsuIsUpperAsciiChar".}=
|
rtl, extern: "nsuIsUpperAsciiChar".} =
|
||||||
## Checks whether or not `c` is an upper case character.
|
## Checks whether or not `c` is an upper case character.
|
||||||
##
|
##
|
||||||
## This checks ASCII characters only.
|
## This checks ASCII characters only.
|
||||||
return c in {'A'..'Z'}
|
return c in {'A'..'Z'}
|
||||||
|
|
||||||
proc isAlphaAscii*(s: string): bool {.noSideEffect, procvar,
|
proc isAlphaAscii*(s: string): bool {.noSideEffect, procvar,
|
||||||
rtl, extern: "nsuIsAlphaAsciiStr".}=
|
rtl, extern: "nsuIsAlphaAsciiStr".} =
|
||||||
## Checks whether or not `s` is alphabetical.
|
## Checks whether or not `s` is alphabetical.
|
||||||
##
|
##
|
||||||
## This checks a-z, A-Z ASCII characters only.
|
## This checks a-z, A-Z ASCII characters only.
|
||||||
|
|
@ -123,10 +119,10 @@ proc isAlphaAscii*(s: string): bool {.noSideEffect, procvar,
|
||||||
|
|
||||||
result = true
|
result = true
|
||||||
for c in s:
|
for c in s:
|
||||||
result = c.isAlphaAscii() and result
|
if not c.isAlphaAscii(): return false
|
||||||
|
|
||||||
proc isAlphaNumeric*(s: string): bool {.noSideEffect, procvar,
|
proc isAlphaNumeric*(s: string): bool {.noSideEffect, procvar,
|
||||||
rtl, extern: "nsuIsAlphaNumericStr".}=
|
rtl, extern: "nsuIsAlphaNumericStr".} =
|
||||||
## Checks whether or not `s` is alphanumeric.
|
## Checks whether or not `s` is alphanumeric.
|
||||||
##
|
##
|
||||||
## This checks a-z, A-Z, 0-9 ASCII characters only.
|
## This checks a-z, A-Z, 0-9 ASCII characters only.
|
||||||
|
|
@ -142,7 +138,7 @@ proc isAlphaNumeric*(s: string): bool {.noSideEffect, procvar,
|
||||||
return false
|
return false
|
||||||
|
|
||||||
proc isDigit*(s: string): bool {.noSideEffect, procvar,
|
proc isDigit*(s: string): bool {.noSideEffect, procvar,
|
||||||
rtl, extern: "nsuIsDigitStr".}=
|
rtl, extern: "nsuIsDigitStr".} =
|
||||||
## Checks whether or not `s` is a numeric value.
|
## Checks whether or not `s` is a numeric value.
|
||||||
##
|
##
|
||||||
## This checks 0-9 ASCII characters only.
|
## This checks 0-9 ASCII characters only.
|
||||||
|
|
@ -158,7 +154,7 @@ proc isDigit*(s: string): bool {.noSideEffect, procvar,
|
||||||
return false
|
return false
|
||||||
|
|
||||||
proc isSpaceAscii*(s: string): bool {.noSideEffect, procvar,
|
proc isSpaceAscii*(s: string): bool {.noSideEffect, procvar,
|
||||||
rtl, extern: "nsuIsSpaceAsciiStr".}=
|
rtl, extern: "nsuIsSpaceAsciiStr".} =
|
||||||
## Checks whether or not `s` is completely whitespace.
|
## Checks whether or not `s` is completely whitespace.
|
||||||
##
|
##
|
||||||
## Returns true if all characters in `s` are whitespace
|
## Returns true if all characters in `s` are whitespace
|
||||||
|
|
@ -172,7 +168,7 @@ proc isSpaceAscii*(s: string): bool {.noSideEffect, procvar,
|
||||||
return false
|
return false
|
||||||
|
|
||||||
proc isLowerAscii*(s: string): bool {.noSideEffect, procvar,
|
proc isLowerAscii*(s: string): bool {.noSideEffect, procvar,
|
||||||
rtl, extern: "nsuIsLowerAsciiStr".}=
|
rtl, extern: "nsuIsLowerAsciiStr".} =
|
||||||
## Checks whether or not `s` contains all lower case characters.
|
## Checks whether or not `s` contains all lower case characters.
|
||||||
##
|
##
|
||||||
## This checks ASCII characters only.
|
## This checks ASCII characters only.
|
||||||
|
|
@ -187,7 +183,7 @@ proc isLowerAscii*(s: string): bool {.noSideEffect, procvar,
|
||||||
true
|
true
|
||||||
|
|
||||||
proc isUpperAscii*(s: string): bool {.noSideEffect, procvar,
|
proc isUpperAscii*(s: string): bool {.noSideEffect, procvar,
|
||||||
rtl, extern: "nsuIsUpperAsciiStr".}=
|
rtl, extern: "nsuIsUpperAsciiStr".} =
|
||||||
## Checks whether or not `s` contains all upper case characters.
|
## Checks whether or not `s` contains all upper case characters.
|
||||||
##
|
##
|
||||||
## This checks ASCII characters only.
|
## This checks ASCII characters only.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue