Skip to content

Commit 51274c1

Browse files
committed
Add some character class tests.
1 parent 5e09f81 commit 51274c1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

wybelibs/wybe/char.wybe

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ pub def fmt(x:_, minlength:int):string = fmt(x, minlength, ' ')
4646
pub def fmt(x:_, minlength:int, fill:_):string =
4747
fmt(string(x), minlength, fill)
4848

49+
pub def {test} is_whitespace(x:_) {
50+
x = ' ' | x = '\t' | x = '\n' | x = '\r' | x = '\f' | x = '\v'
51+
}
52+
53+
pub def {test} is_digit(x:_) { x >= '0' & x <= '9' }
54+
55+
pub def {test} is_upper(x:_) { x >= 'A' & x <= 'Z' }
56+
57+
pub def {test} is_lower(x:_) { x >= 'a' & x <= 'z' }
58+
59+
pub def {test} is_alpha(x:_) { is_upper(x) | is_lower(x) }
60+
61+
pub def {test} is_alphanumeric(x:_) { is_alpha(x) | is_digit(x) }
4962

5063
## I/O
5164

0 commit comments

Comments
 (0)