| Author |
Regular Expression problem
|
tihor Gupta
Greenhorn
Joined: Jan 12, 2011
Posts: 1
|
|
I want to create pattern for checking a string such that it contains numbers 0-9. Its length should be 2-3. But it should not contain 00 or 000.
How can i create a regular expression for this.
Rohit
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 9948
|
|
|
What have you tried? We generally don't just hand out answers, but expect you to show some kind of effort first. Post the regex you've written so far, and we can work from that.
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
|
|
And welcome to JavaRanch
|
 |
Stefaan Dutry
Ranch Hand
Joined: Sep 17, 2010
Posts: 32
|
|
Although at first it sounds realy easy you need quite a few regex constructs.
A possible solution i have in mind(and tested) involves using the following regex elements:
quantifiersboundary matchersnegative lookahead
Some usefull links are:
Pattern javadoconline regex testerjava regex tutorial
Post what you have so far and i'll see how i can help.
|
 |
 |
|
|
subject: Regular Expression problem
|
|
|