From 6bed60c6d0703dcabbcc92231fd044b005143c7c Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Tue, 8 Dec 2015 14:15:37 -0500 Subject: [PATCH] lib/core: Added new `is_hexdigit` service on `Char` Signed-off-by: Lucas Bajolet --- lib/core/text/abstract_text.nit | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/core/text/abstract_text.nit b/lib/core/text/abstract_text.nit index 76823e2..cacee99 100644 --- a/lib/core/text/abstract_text.nit +++ b/lib/core/text/abstract_text.nit @@ -1709,6 +1709,16 @@ redef class Char return (self >= 'a' and self <= 'z') or (self >= 'A' and self <= 'Z') end + # Is `self` an hexadecimal digit ? + # + # assert 'A'.is_hexdigit + # assert not 'G'.is_hexdigit + # assert 'a'.is_hexdigit + # assert not 'g'.is_hexdigit + # assert '5'.is_hexdigit + fun is_hexdigit: Bool do return (self >= '0' and self <= '9') or (self >= 'A' and self <= 'F') or + (self >= 'a' and self <= 'f') + # Returns true if the char is an alpha or a numeric digit # # assert 'a'.is_alphanumeric -- 1.7.9.5