[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

input question

John Joyce

9/16/2007 2:09:00 AM

I must have forgotten something dreadfully simple.
How do I limit input (from stdin in this case) so that the first non
AlphaNumeric ends input?
I fiddled with gets and with $/ to no avail.
I know I could do input validation later, and I could (should)
normally use buffered input.
gets uses the default \n to end input.
I'd like to end it at the first non-alpha-numeric.
(Ideally, eventually a language specific version would be beautiful
to handle unicode codepoint ranges similarly)

Any ideas?
Or a method that I'm just missing?

1 Answer

yermej

9/16/2007 3:46:00 AM

0

On Sep 15, 9:08 pm, John Joyce <dangerwillrobinsondan...@gmail.com>
wrote:
> I must have forgotten something dreadfully simple.
> How do I limit input (from stdin in this case) so that the first non
> AlphaNumeric ends input?
> I fiddled with gets and with $/ to no avail.
> I know I could do input validation later, and I could (should)
> normally use buffered input.
> gets uses the default \n to end input.
> I'd like to end it at the first non-alpha-numeric.
> (Ideally, eventually a language specific version would be beautiful
> to handle unicode codepoint ranges similarly)
>
> Any ideas?
> Or a method that I'm just missing?

Perhaps there's a better way, but my first thought would be to accept
one character at a time, check each one for the required condition,
and continue with processing once you've found what you're looking
for. There was a recent discussion on how to get just one character at
a time without pressing Enter after each -- http://tinyurl....
if you need it.

Jeremy