Solved

Regex for Integer Equal to or greater than 100

Posted on 2013-12-06
8
1,684 Views
Last Modified: 2013-12-06
Need a regex for integers equal to or greater than 100.
0
Comment
Question by:894359
  • 3
  • 3
  • 2
8 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 39702545
You can use:

^(1\d\d|\d{4,})$

Open in new window

0
 

Author Comment

by:894359
ID: 39702557
Hi,
This doesn't work . try 999 or any number that doesn't start with a 1 and is 3 digits long.
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 39702563
My apologies. I was writing that on the way out of the door of the office. Corrected:

^([1-9]\d\d|[1-9]\d{3,})$

Open in new window

0
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 39702566
Shorter version:

^[1-9]\d\d\d*$

Open in new window

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 82

Expert Comment

by:leakim971
ID: 39702585
Why a regex?

if( i * 1 >= 100 ) { // in term of performance it's faster than a regex !
   alert("your integer is equal to or greater than 100!")
}
0
 

Author Comment

by:894359
ID: 39702606
I have to use a regex. it is for a tool.
0
 

Author Closing Comment

by:894359
ID: 39702608
Thank you!
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39702624
So why Javascript topic? Anyway, if you're happy, I'm happy... and I think kaufmed is happy too :)

Have a nice week-end!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now