input question

J

John Joyce

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?
 
Y

yermej

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.com/38w5fv
if you need it.

Jeremy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,264
Messages
2,571,323
Members
48,007
Latest member
Elvis60357

Latest Threads

Top