•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 423,365 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 5,025 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 1577 | Replies: 4
![]() |
•
•
Join Date: Aug 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
Hi Folks,
I have been searching to find a reglular expression that deals with decimal points, they are not mentioned on the Sun Tutorials for Regular Expressions. Basically im trying to verify that a string taken in from a screen matches the format of (15).99. This is not for my homework assignment:-) If anyone even knows of a good tutorial that covers this, that would be great as im kinda new to Java development.
Thanks
Man In A Can
I have been searching to find a reglular expression that deals with decimal points, they are not mentioned on the Sun Tutorials for Regular Expressions. Basically im trying to verify that a string taken in from a screen matches the format of (15).99. This is not for my homework assignment:-) If anyone even knows of a good tutorial that covers this, that would be great as im kinda new to Java development.
Thanks
Man In A Can
1. check for the number of decimal points in the input. if this is not 1 => false
2. check that everything before the decimal point is a decimal. if not => false
3. check that everything after the decimal point is a decimal if not so=> false
4. check the number of decimals after the decimal pont. if not two => false
if all these checks cleared, you've got a match. don't know whether or not regex has a quick sollution for it, but you could as well do it without
2. check that everything before the decimal point is a decimal. if not => false
3. check that everything after the decimal point is a decimal if not so=> false
4. check the number of decimals after the decimal pont. if not two => false
if all these checks cleared, you've got a match. don't know whether or not regex has a quick sollution for it, but you could as well do it without
You can simplify it just a little more with a digit character match like so
You might find this small regex testing form that I posted a while back helpful in tweaking patterns as you are experimenting: http://www.daniweb.com/forums/post392585-8.html
The numbered text fields at the bottom are the match group results of the pattern.
\d{0,15}\.\d{0,2}The numbered text fields at the bottom are the match group results of the pattern.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Previous Thread: BOM Problem with crimson Parser
- Next Thread: Java and Javax?



Linear Mode