# Regular expression

**URL:** <https://www.ruby-forum.com/t/regular-expression/170648>\
**Category:** Rails\
**Created:** [June 20, 2009, 7:44am UTC](https://www.ruby-forum.com/t/regular-expression/170648 "2009-06-20T07:44:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [June 20, 2009, 7:44am UTC](https://www.ruby-forum.com/t/regular-expression/170648/1 "2009-06-20T07:44:15Z")

</div>

hi friends…  
in my application i have number of days field.  
it Should not allow user to input special characters in the field.and it  
Should not allow blank space in the Number of Days field.  
what regular expression can i use…  
Thanks a lot

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [June 20, 2009, 7:48am UTC](https://www.ruby-forum.com/t/regular-expression/170648/2 "2009-06-20T07:48:24Z")

</div>

\d+

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [June 20, 2009, 7:49am UTC](https://www.ruby-forum.com/t/regular-expression/170648/3 "2009-06-20T07:49:34Z")

</div>

Perhaps it’s best if you try, and then if you fail ask the question?  
Otherwise you will be asking on the list everytime you need a regular  
expression

I recomment the following

> **[Regular Expressions Cheat Sheet](https://cheatography.com/davechild/cheat-sheets/regular-expressions/)**
>
> A quick reference guide for regular expressions (regex), including symbols, ranges, grouping, assertions and some sample patterns to get you started.

Simon

On Sat, 20 Jun 2009 13:44:15 +0800, Newb N.

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [June 20, 2009, 8:07am UTC](https://www.ruby-forum.com/t/regular-expression/170648/4 "2009-06-20T08:07:40Z")

</div>

Simon M. wrote:

> Perhaps it’s best if you try, and then if you fail ask the question?  
> Otherwise you will be asking on the list everytime you need a regular  
> expression
> 
> I recomment the following  
> [Regular Expressions Cheat Sheet by DaveChild - Download free from Cheatography - Cheatography.com: Cheat Sheets For Every Occasion](http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/)
> 
> Simon
> 
> On Sat, 20 Jun 2009 13:44:15 +0800, Newb N.

Sorry for my ignorance,  
actually i tried but i dont know how limit the input upto two digits…  
that is i Should limit the input to two digits in the field.  
it should accept 20 and 5 but not 120…  
that s my confusion…  
Thanks for ur Reply

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [June 20, 2009, 9:04am UTC](https://www.ruby-forum.com/t/regular-expression/170648/5 "2009-06-20T09:04:22Z")

</div>

1. Please refrain from bumping your topic so often, you clearly stated  
your request in a previous post, there is no need to repost with no  
added information 10 minutes later. The only thing you might achieve  
is to deter people that may help you.
2. Most people here don’t mind helping people who are obviously stuck,  
but will mostly ignore those who are blatantly lazy and don’t even  
care to read the links given them.

Am 20.06.2009 um 08:18 schrieb Newb N.:

> Is it possible to limit the input upto two digits using regex

1. Which brings me to the point: Have you even read _in full_ the link  
Simon gave you? There is a box called “Quantifiers”, with which you  
can specify the number of occurrences of a certain pattern in your  
regex. Please go read up on that, or for that matter on any of the top  
results google yields for “ruby regex” or something like that, and if  
you still have problems understanding what is written there, come back  
and ask, if you are just too lazy to make even that little bit of  
research for yourself, then please stay away from this forum, thank you.

Felix

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [June 20, 2009, 8:18am UTC](https://www.ruby-forum.com/t/regular-expression/170648/6 "2009-06-20T08:18:23Z")

</div>

Is it possible to limit the input upto two digits using regex
