# Input question

**URL:** <https://www.ruby-forum.com/t/input-question/114731>\
**Category:** Ruby\
**Created:** [September 17, 2007, 1:24pm UTC](https://www.ruby-forum.com/t/input-question/114731 "2007-09-17T13:24:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [September 17, 2007, 1:24pm UTC](https://www.ruby-forum.com/t/input-question/114731/1 "2007-09-17T13:24:52Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [September 17, 2007, 1:25pm UTC](https://www.ruby-forum.com/t/input-question/114731/2 "2007-09-17T13:25:04Z")

</div>

On Sep 15, 9:08 pm, John J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> 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](http://tinyurl.com/38w5fv)  
if you need it.

Jeremy
