Hi,
what's the best way to check whether a String consists of printable
characters only? (In C: isprint from ctype)
Maybe would be nice to have the ctype classes as patterns in the
regular expressions.
regards
Hadmut
Hi,
what's the best way to check whether a String consists of printable
characters only? (In C: isprint from ctype)
Maybe would be nice to have the ctype classes as patterns in the
regular expressions.
regards
Hadmut
Hi Hadmut,
what's the best way to check whether a String consists of
printable characters only? (In C: isprint from ctype)Maybe would be nice to have the ctype classes as patterns
in the regular expressions.
It's your lucky day:
"a b c" =~ /\A[[:print:]]*\z/ #=> 0
"a \0 c" =~ /\A[[:print:]]*\z/ #=> nil
--
Daniel Brockman <daniel@brockman.se>
So really, we all have to ask ourselves:
Am I waiting for RMS to do this? --TTN.
Hadmut Danisch wrote:
Hi,
what's the best way to check whether a String consists of printable
characters only? (In C: isprint from ctype)Maybe would be nice to have the ctype classes as patterns in the
regular expressions.regards
Hadmut
See also: http://rubyforge.org/projects/ctype/
Regards,
Dan
is that locale senstive?
-a
On Thu, 28 Jul 2005, Daniel Brockman wrote:
Hi Hadmut,
what's the best way to check whether a String consists of
printable characters only? (In C: isprint from ctype)Maybe would be nice to have the ctype classes as patterns
in the regular expressions.It's your lucky day:
"a b c" =~ /\A[[:print:]]*\z/ #=> 0
"a \0 c" =~ /\A[[:print:]]*\z/ #=> nil
email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
My religion is very simple. My religion is kindness.
--Tenzin Gyatso
===============================================================================
Daniel Brockman wrote:
It's your lucky day:
"a b c" =~ /\A[[:print:]]*\z/ #=> 0
"a \0 c" =~ /\A[[:print:]]*\z/ #=> nil
Great, thanks.
(I should start to read the manual...)
Hadmut
Hi,
In message "Re: ctype / isprint ?"
"a b c" =~ /\A[[:print:]]*\z/ #=> 0
"a \0 c" =~ /\A[[:print:]]*\z/ #=> nil
is that locale senstive?
1.8 regex uses C ctype macros, so that it is locale sensitive.
Oniguruma (1.9 regex engine) does not use locales. It uses encoding
information, since C locale model is just not suitable to handle
multiple encoding schemes in a program, like Oniguruma does.
matz.