473,414 Members | 1,738 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,414 software developers and data experts.

problem with a regular expression

Hi,
I would like to build a regular expression that allows
only a number with 3 integer the decimals separator and
other three decimals.
I've build the firt part in this way:
^([1-9]{1}|[1-9]{1}[0-9]{1}|100)$

Now I'am tring to build the second one but... it's quite
difficult.
Somebody could help me? This is what I've done:
^([1-9]{1}|[1-9]{1}[0-9]{1}|100)\.([0-9]{1}|[0-9]{2}|[0-9]
{3})$

But it doesn't work as I would... :-\
Thanks in advance!
Nov 15 '05 #1
3 2037
Chris probably hasn't seen this post yet :-)

try this while you wait
www.regexlib.com

"giulio santorini" <gi**************@yahoo.it> wrote in message
news:09****************************@phx.gbl...
Hi,
I would like to build a regular expression that allows
only a number with 3 integer the decimals separator and
other three decimals.
I've build the firt part in this way:
^([1-9]{1}|[1-9]{1}[0-9]{1}|100)$

Now I'am tring to build the second one but... it's quite
difficult.
Somebody could help me? This is what I've done:
^([1-9]{1}|[1-9]{1}[0-9]{1}|100)\.([0-9]{1}|[0-9]{2}|[0-9]
{3})$

But it doesn't work as I would... :-\
Thanks in advance!

Nov 15 '05 #2
In article <09****************************@phx.gbl>,
"giulio santorini" <gi**************@yahoo.it> wrote:
Now I'am tring to build the second one but... it's quite
difficult.
Somebody could help me? This is what I've done:
^([1-9]{1}|[1-9]{1}[0-9]{1}|100)\.([0-9]{1}|[0-9]{2}|[0-9]
{3})$

But it doesn't work as I would... :-\

Tell us what you expect to happen, what actually happens, and why you
don't think that's right.

Give some examples of strings on which it should work but doesn't.
Give some examples of strings on which it shouldn't work but does.


All that aside, are you escaping the escape character--so that C#
doesn't digest your \ ? That is, you have the following, right?

^([1-9]{1}|[1-9]{1}[0-9]{1}|100)\\.( etc. )$

That is, \\. instead of \.
By the way, the {1} quantifiers are redundant. You could probably get
away with the following:

Regex r = new Regex("^([1-9][0-9]?|100)\\.([0-9]{1,3})$");
That regex looks for:
* the start of the string

then either

* one digit between 1 and 9
* and, optionally, one digit between 0 and 9

or

* the string 100

* a decimal point

* between one and three digits, each between 0 and 9

* the end of the string
Nov 15 '05 #3
see also Eric Gunnerson's Regular Expression workbench. This is quite
useful for figuring out what your expression is doing and getting it
to work.

http://www.gotdotnet.com/Community/U...1-4ee2729d7322

As guiulio mentioned, make sure you either escape your backslashes
(\\) or to make life simpler, always use @ in front of the whole
string.

string pattern = @"^mypatter\.with[1-9]funky\.characters$";

-mike mayer

"giulio santorini" <gi**************@yahoo.it> wrote in message
news:09****************************@phx.gbl...
Hi,
I would like to build a regular expression that allows
only a number with 3 integer the decimals separator and
other three decimals.
I've build the firt part in this way:
^([1-9]{1}|[1-9]{1}[0-9]{1}|100)$

Now I'am tring to build the second one but... it's quite
difficult.
Somebody could help me? This is what I've done:
^([1-9]{1}|[1-9]{1}[0-9]{1}|100)\.([0-9]{1}|[0-9]{2}|[0-9]
{3})$

But it doesn't work as I would... :-\
Thanks in advance!

Nov 15 '05 #4

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

Similar topics

4
by: andrewflanders | last post by:
I have an associative array of keys and values. I want to search a string for the existance of keys and replace them with the values in the array. The problem is that some of the keys resemble...
4
by: Buddy | last post by:
Can someone please show me how to create a regular expression to do the following My text is set to MyColumn{1, 100} Test I want a regular expression that sets the text to the following...
11
by: Dimitris Georgakopuolos | last post by:
Hello, I have a text file that I load up to a string. The text includes certain expression like {firstName} or {userName} that I want to match and then replace with a new expression. However,...
3
by: Senna | last post by:
Hi all, Thru a HttpWebRequest and HttpWebResponse I get html like this(<pre> excluded). <pre> <tr> <td valign="top" align="right" class="SgSVT1BG" nowrap style=" padding-right: 6px "><div...
4
by: | last post by:
Here is an interesting one. Running asp.net 2.0 beta 2. I have a regular expression used in a regex validator that works on the client side in Firefox but not in IE. Any ideas? IE always reports...
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: 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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.