473,402 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Regular Expression for numbers like 12345.67, 123.45, 12.34, etc.

I am looking for a regular expression that would filter numbers in my vb.net
application. The integer part could have up to 5 digits and the fractional
part up to 2 digits.

I came up with the regex pattern of ^[0-9]{1,5}$ for Five decimal digits
or less but I couldn't finish the expression for the fractional part.

Thanks in adance.
--
Dave B.
Jun 26 '07 #1
4 2967

"dmbuso" <dm*****@community.nospamwrote in message
news:5A**********************************@microsof t.com...
>I am looking for a regular expression that would filter numbers in my
vb.net
application. The integer part could have up to 5 digits and the fractional
part up to 2 digits.

I came up with the regex pattern of ^[0-9]{1,5}$ for Five decimal
digits
or less but I couldn't finish the expression for the fractional part.

Thanks in adance.
--
Dave B.
Sorry not close to VS right now but if you use reg exe lots this tool (free)
is what you need.

http://www.ultrapico.com/Expresso.htm

Hope this helps
LLoyd Sheen

Jun 26 '07 #2


"dmbuso" <dm*****@community.nospamwrote in message
news:5A**********************************@microsof t.com...
>I am looking for a regular expression that would filter numbers in my
vb.net
application. The integer part could have up to 5 digits and the fractional
part up to 2 digits.

I came up with the regex pattern of ^[0-9]{1,5}$ for Five decimal
digits
or less but I couldn't finish the expression for the fractional part.

Thanks in adance.
--
Dave B.
One that works for me (tested a few numbers):

^\d{1,5}(\.\d{1,2})?$

HTH,
Mythran
Jun 26 '07 #3
GS
or you can try
^\d{1,5}(\.\d{1,2}){0,1}$
assuming no decimal pt allowed when no fractional part, also rejects any
extra dec pt

"dmbuso" <dm*****@community.nospamwrote in message
news:5A**********************************@microsof t.com...
I am looking for a regular expression that would filter numbers in my
vb.net
application. The integer part could have up to 5 digits and the fractional
part up to 2 digits.

I came up with the regex pattern of ^[0-9]{1,5}$ for Five decimal
digits
or less but I couldn't finish the expression for the fractional part.

Thanks in adance.
--
Dave B.

Jun 26 '07 #4

"dmbuso" <dm*****@community.nospamwrote in message
news:5A**********************************@microsof t.com...
>I am looking for a regular expression that would filter numbers in my
vb.net
application. The integer part could have up to 5 digits and the fractional
part up to 2 digits.

I came up with the regex pattern of ^[0-9]{1,5}$ for Five decimal
digits
or less but I couldn't finish the expression for the fractional part.

Thanks in adance.
--
Dave B.
^(?<Int>\d{1,5})(?<Dec>(?<Pt>[\.,])\d{1,2})?$

The above will handle 1-5 digits followed by either a . or , (intl you
know). Then up to 2 digits.

It will return the following for the value (12123,23)
Int = 12123
Dec = ,23
Pt = ,

Hope this helps
Lloyd Sheen

Jun 26 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Tina Li | last post by:
Hello, I've been struggling with a regular expression for parsing XML files, which keeps giving the run time error "maximum recursion limit exceeded". Here is the pattern string: ...
1
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make...
0
by: Mike | last post by:
I'm trying to come up with a regular expression that matches numbers with commas... but doesn't match numbers formatted without commas. The problem is that I'm trying to parse a file where the...
4
by: Arne | last post by:
Hi, I'm trying to recognise phone numbers on the following format using regular expressions: +47 123 45 678 This should be recognised by the following regular expression: +47 \d{3} \d{2}...
2
by: Phi! | last post by:
Hello everyone, I have had a look at some newsgroup articles but cannot seem to find anything to hekp me so please bear with me if this is a simple question. I am using Regular expressions...
3
by: James D. Marshall | last post by:
The issue at hand, I believe is my comprehension of using regular expression, specially to assist in replacing the expression with other text. using regular expression (\s*) my understanding is...
3
by: Zach | last post by:
Hello, Please forgive if this is not the most appropriate newsgroup for this question. Unfortunately I didn't find a newsgroup specific to regular expressions. I have the following regular...
10
by: venugopal.sjce | last post by:
Hi Friends, I'm constructing a regular expression for validating an expression which looks as any of the following forms: 1. =4*++2 OR 2. =Sum()*6 Some of the samples I have constructed...
8
by: cokofreedom | last post by:
I was reading up on this site http://www.noulakaz.net/weblog/ 2007/03/18/a-regular-expression-to-check-for-prime-numbers/] of an interesting way to work out prime numbers using Regular Expression....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.