Two Laptop Bag*
The moose likes Java in General and the fly likes simple regex problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "simple regex problem" Watch "simple regex problem" New topic
Author

simple regex problem

Shilpa Tendulkar
Ranch Hand

Joined: Jul 29, 2001
Posts: 75
Hi All

I am stuck with this simple regex. Here is my code


wheather string is 123 or 123a, it always prints non numeric..

Any clue???
Prabhakar Reddy Bokka
Ranch Hand

Joined: Jul 26, 2005
Posts: 189

In the code \\d stands for degit.

Try this


SCJP 5, SCWCD 5
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

More precisely, "\\d" matches only one digit. If you want to match one or more digit, you'll have to add "+" quantifier.


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: simple regex problem
 
Similar Threads
Another Dan's erroneous definition?
A simple RegEx just doesn't make sense...
Regex
Literal
Regular expression to check for specific special characters (any repitition) and 0 to 9 numbers