473,657 Members | 2,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regular expression for validating [GrandTotal]=4*[TotalCharges]+[currentCharges]+2

Hi Friends,

I'm constructing a regular expression for validating an expression
which looks as any of the following forms:

1. [GrandTotal]=4*[TotalCharges]+[currentCharges]+2
OR
2. [TotalCharges]=Sum([CurrentCharges])*6

Some of the samples I have constructed below:

StringEx RegEx
[alphaNumeric] --- ^\[[a-zA-Z]+[0-9]*\]$
[TotalCharges]+2 --- ^\[[a-zA-Z]+[0-9]*\](\
+[0-9]*)*$
[TotalCharges]/22+5/6*8---^\[[a-zA-Z]+[0-9]*\]([\+\-\*\/][0-9]*)*$
[TotalCharges]/22+5/6*8+[currChrgs] ---->^\[[a-zA-Z]+[0-9]*\]([\+\-\*
\/][0-9]*)*([\+\-\*\/]\[[a-zA-Z]+[0-9]*\])*$
2*[TotalCharges]/22+5/6*8+[currChrgs] ----->^([0-9]*[\+\-\*\/])*\[[a-
zA-Z]+[0-9]*\]([\+\-\*\/][0-9]*)*([\+\-\*\/]\[[a-zA-Z]+[0-9]*\])*$

Pls help me... I'm badly in need of this in my project.

Thanks in advance...
Venu.

Nov 6 '07 #1
10 1663
Hello ve************@ gmail.com,
Hi Friends,

I'm constructing a regular expression for validating an expression
which looks as any of the following forms:

1. [GrandTotal]=4*[TotalCharges]+[currentCharges]+2
OR
2. [TotalCharges]=Sum([CurrentCharges])*6
Some of the samples I have constructed below:

StringEx RegEx
[alphaNumeric] --- ^\[[a-zA-Z]+[0-9]*\]$
[TotalCharges]+2 --- ^\[[a-zA-Z]+[0-9]*\](\
+[0-9]*)*$
[TotalCharges]/22+5/6*8---^\[[a-zA-Z]+[0-9]*\]([\+\-\*\/][0-9]*)*$
[TotalCharges]/22+5/6*8+[currChrgs] ---->^\[[a-zA-Z]+[0-9]*\]([\+\-\*
\/][0-9]*)*([\+\-\*\/]\[[a-zA-Z]+[0-9]*\])*$
2*[TotalCharges]/22+5/6*8+[currChrgs] ----->^([0-9]*[\+\-\*\/])*\[[a-
zA-Z]+[0-9]*\]([\+\-\*\/][0-9]*)*([\+\-\*\/]\[[a-zA-Z]+[0-9]*\])*$
Pls help me... I'm badly in need of this in my project.
A parser would be a much better solutio than a regular expression. Microsoft
recently started shipping Mplex/MPPG with the Visual Studio SDK, you might
be able to use these

http://www.google.nl/search?q=mplex+...ient=firefox-a

though the following might work:
(?<var\[[^\]]) = ([0-9]+|[[^\]]|(sum|avg|count )\([0-9]+|[[^\]]\))([+/*-]([0-9]+|[[^\]]|(sum|avg|count )\([0-9]+|[[^\]]\)))*

It does not take nested functions into account, nor does it allow complex
expressions inside a function (sum|avg|count) . You might be able to get it
working.

Good luck :)

--
Jesse Houwing
jesse.houwing at sogeti.nl
Nov 6 '07 #2
On Nov 6, 2:53 pm, Jesse Houwing <jesse.houw...@ newsgroup.nospa m>
wrote:
Hello venugopal.s...@ gmail.com,


Hi Friends,
I'm constructing a regular expression for validating an expression
which looks as any of the following forms:
1. [GrandTotal]=4*[TotalCharges]+[currentCharges]+2
OR
2. [TotalCharges]=Sum([CurrentCharges])*6
Some of the samples I have constructed below:
StringEx RegEx
[alphaNumeric] --- ^\[[a-zA-Z]+[0-9]*\]$
[TotalCharges]+2 --- ^\[[a-zA-Z]+[0-9]*\](\
+[0-9]*)*$
[TotalCharges]/22+5/6*8---^\[[a-zA-Z]+[0-9]*\]([\+\-\*\/][0-9]*)*$
[TotalCharges]/22+5/6*8+[currChrgs] ---->^\[[a-zA-Z]+[0-9]*\]([\+\-\*
\/][0-9]*)*([\+\-\*\/]\[[a-zA-Z]+[0-9]*\])*$
2*[TotalCharges]/22+5/6*8+[currChrgs] ----->^([0-9]*[\+\-\*\/])*\[[a-
zA-Z]+[0-9]*\]([\+\-\*\/][0-9]*)*([\+\-\*\/]\[[a-zA-Z]+[0-9]*\])*$
Pls help me... I'm badly in need of this in my project.

A parser would be a much better solutio than a regular expression. Microsoft
recently started shipping Mplex/MPPG with the Visual Studio SDK, you might
be able to use these

http://www.google.nl/search?q=mplex+...f-8&aq=t&rls=o...

though the following might work:
(?<var\[[^\]]) = ([0-9]+|[[^\]]|(sum|avg|count )\([0-9]+|[[^\]]\))([+/*-]([0-9]+|[[^\]]|(sum|*avg|coun t)\([0-9]+|[[^\]]\)))*

It does not take nested functions into account, nor does it allow complex
expressions inside a function (sum|avg|count) . You might be able to get it
working.

Good luck :)

--
Jesse Houwing
jesse.houwing at sogeti.nl- Hide quoted text -

- Show quoted text -

Hi Jesse,

(?<var\[[^\]]) = ([0-9]+|[[^\]]|(sum|avg|count )\([0-9]+|[[^\]]\))([+/
*-]([0-9]+|[[^\]]|(sum|*avg|coun t)\([0-9]+|[[^\]]\)))*

(?<var\[[^\]]) is giving the error as invalid group name..

Nov 6 '07 #3
Hello ve************@ gmail.com,
On Nov 6, 2:53 pm, Jesse Houwing <jesse.houw...@ newsgroup.nospa m>
wrote:
>Hello venugopal.s...@ gmail.com,
>>Hi Friends,

I'm constructing a regular expression for validating an expression
which looks as any of the following forms:

1. [GrandTotal]=4*[TotalCharges]+[currentCharges]+2
OR
2. [TotalCharges]=Sum([CurrentCharges])*6
Some of the samples I have constructed below:
StringEx RegEx
[alphaNumeric] --->
^\[[a-zA-Z]+[0-9]*\]$
[TotalCharges]+2 --->
^\[[a-zA-Z]+[0-9]*\](\
+[0-9]*)*$
[TotalCharges]/22+5/6*8---^\[[a-zA-Z]+[0-9]*\]([\+\-\*\/][0-9]*)*$
[TotalCharges]/22+5/6*8+[currChrgs]
---->^\[[a-zA-Z]+[0-9]*\]([\+\-\*
\/][0-9]*)*([\+\-\*\/]\[[a-zA-Z]+[0-9]*\])*$
2*[TotalCharges]/22+5/6*8+[currChrgs]
----->^([0-9]*[\+\-\*\/])*\[[a-
zA-Z]+[0-9]*\]([\+\-\*\/][0-9]*)*([\+\-\*\/]\[[a-zA-Z]+[0-9]*\])*$
Pls help me... I'm badly in need of this in my project.
A parser would be a much better solutio than a regular expression.
Microsoft recently started shipping Mplex/MPPG with the Visual Studio
SDK, you might be able to use these

http://www.google.nl/search?q=mplex+...f-8&aq=t&rls=o
...

though the following might work:
(?<var\[[^\]]) =
([0-9]+|[[^\]]|(sum|avg|count )\([0-9]+|[[^\]]\))([+/*-]([0-9]+|[[^\]]
|(sum|?avg|cou nt)\([0-9]+|[[^\]]\)))*
It does not take nested functions into account, nor does it allow
complex expressions inside a function (sum|avg|count) . You might be
able to get it working.

Good luck :)

--
Jesse Houwing
jesse.houwin g at sogeti.nl- Hide quoted text -
- Show quoted text -
Hi Jesse,

(?<var\[[^\]]) = ([0-9]+|[[^\]]|(sum|avg|count )\([0-9]+|[[^\]]\))([+/
*-]([0-9]+|[[^\]]|(sum|?avg|coun t)\([0-9]+|[[^\]]\)))*

(?<var\[[^\]]) is giving the error as invalid group name..
Seems I lost a in there

(?<var>\[[^\]])

And made a few errors on the way. I guess it happened when going from one
virtual pc to the next. I tested and expanded the expression and this is
what I ended up with:

\[[^\]]*\][ ]*=[ ]*([0-9]+|\[[^\]]*\]|(sum|avg|count )\([ ]*([0-9]+|\[[^\]]*\])[
]*\))([ ]*[-+*/][ ]*([0-9]+|\[[^\]]*\]|(sum|avg|count )\([ ]*([0-9]+|\[[^\]]*\])[
]*\)))*

Tested this time ;)
--
Jesse Houwing
jesse.houwing at sogeti.nl
Nov 6 '07 #4
On Nov 6, 4:51 pm, Jesse Houwing <jesse.houw...@ newsgroup.nospa m>
wrote:
Hello venugopal.s...@ gmail.com,


On Nov 6, 2:53 pm, Jesse Houwing <jesse.houw...@ newsgroup.nospa m>
wrote:
Hello venugopal.s...@ gmail.com,
>Hi Friends,
>I'm constructing a regular expression for validating an expression
which looks as any of the following forms:
>1. [GrandTotal]=4*[TotalCharges]+[currentCharges]+2
OR
2. [TotalCharges]=Sum([CurrentCharges])*6
Some of the samples I have constructed below:
StringEx RegEx
[alphaNumeric] --->
^\[[a-zA-Z]+[0-9]*\]$
[TotalCharges]+2 --->
^\[[a-zA-Z]+[0-9]*\](\
+[0-9]*)*$
[TotalCharges]/22+5/6*8---^\[[a-zA-Z]+[0-9]*\]([\+\-\*\/][0-9]*)*$
[TotalCharges]/22+5/6*8+[currChrgs]
---->^\[[a-zA-Z]+[0-9]*\]([\+\-\*
\/][0-9]*)*([\+\-\*\/]\[[a-zA-Z]+[0-9]*\])*$
2*[TotalCharges]/22+5/6*8+[currChrgs]
----->^([0-9]*[\+\-\*\/])*\[[a-
zA-Z]+[0-9]*\]([\+\-\*\/][0-9]*)*([\+\-\*\/]\[[a-zA-Z]+[0-9]*\])*$
Pls help me... I'm badly in need of this in my project.
A parser would be a much better solutio than a regular expression.
Microsoft recently started shipping Mplex/MPPG with the Visual Studio
SDK, you might be able to use these
>http://www.google.nl/search?q=mplex+...f-8&aq=t&rls=o
...
though the following might work:
(?<var\[[^\]]) =
([0-9]+|[[^\]]|(sum|avg|count )\([0-9]+|[[^\]]\))([+/*-]([0-9]+|[[^\]]
|(sum|?avg|coun t)\([0-9]+|[[^\]]\)))*
It does not take nested functions into account, nor does it allow
complex expressions inside a function (sum|avg|count) . You might be
able to get it working.
Good luck :)
--
Jesse Houwing
jesse.houwing at sogeti.nl- Hide quoted text -
- Show quoted text -
Hi Jesse,
(?<var\[[^\]]) = ([0-9]+|[[^\]]|(sum|avg|count )\([0-9]+|[[^\]]\))([+/
*-]([0-9]+|[[^\]]|(sum|?avg|coun t)\([0-9]+|[[^\]]\)))*
(?<var\[[^\]]) is giving the error as invalid group name..

Seems I lost a in there

(?<var>\[[^\]])

And made a few errors on the way. I guess it happened when going from one
virtual pc to the next. I tested and expanded the expression and this is
what I ended up with:

\[[^\]]*\][ ]*=[ ]*([0-9]+|\[[^\]]*\]|(sum|avg|count )\([ ]*([0-9]+|\[[^\]]*\])[
]*\))([ ]*[-+*/][ ]*([0-9]+|\[[^\]]*\]|(sum|avg|count )\([ ]*([0-9]+|\[[^\]]*\])[
]*\)))*

Tested this time ;)

--
Jesse Houwing
jesse.houwing at sogeti.nl- Hide quoted text -

- Show quoted text -
Hi Jesse,

Thank you very much. It's working. I Just made the following change:
^\[[a-zA-z]+([0-9])*\][ ]*=[ ]*([0-9]+|\[[a-zA-z]+([0-9])*\]|(sum|avg|
count)\([ ]*([0-9]+|\[[a-zA-z]+([0-9])*\])[
]*\))([ ]*[-+*/][ ]*([0-9]+|\[[a-zA-z]+([0-9])*\]|(sum|avg|count )\
([ ]*([0-9]+|\[[a-zA-z]+([0-9])*\])[
]*\)))*$

because, earlier it was taking space inside [ and ] like [current
charges].

let's see together for further improvement of this :)

Thanks and Regards,
Venu
venugopal.sjce at gmail.com

Nov 7 '07 #5
Hello ve************@ gmail.com,
On Nov 6, 4:51 pm, Jesse Houwing <jesse.houw...@ newsgroup.nospa m>
wrote:
>Hello venugopal.s...@ gmail.com,
>>On Nov 6, 2:53 pm, Jesse Houwing <jesse.houw...@ newsgroup.nospa m>
wrote:

Hello venugopal.s...@ gmail.com,

Hi Friends,
>
I'm constructing a regular expression for validating an expression
which looks as any of the following forms:
>
1. [GrandTotal]=4*[TotalCharges]+[currentCharges]+2
OR
2. [TotalCharges]=Sum([CurrentCharges])*6
Some of the samples I have constructed below:
StringEx RegEx
[alphaNumeric] --->
^\[[a-zA-Z]+[0-9]*\]$
[TotalCharges]+2 --->
^\[[a-zA-Z]+[0-9]*\](\
+[0-9]*)*$
[TotalCharges]/22+5/6*8--->
^\[[a-zA-Z]+[0-9]*\]([\+\-\*\/][0-9]*)*$
[TotalCharges]/22+5/6*8+[currChrgs]
---->^\[[a-zA-Z]+[0-9]*\]([\+\-\*
\/][0-9]*)*([\+\-\*\/]\[[a-zA-Z]+[0-9]*\])*$
2*[TotalCharges]/22+5/6*8+[currChrgs]
----->^([0-9]*[\+\-\*\/])*\[[a-
zA-Z]+[0-9]*\]([\+\-\*\/][0-9]*)*([\+\-\*\/]\[[a-zA-Z]+[0-9]*\])*$
Pls help me... I'm badly in need of this in my project.
A parser would be a much better solutio than a regular expression.
Microsoft recently started shipping Mplex/MPPG with the Visual
Studio SDK, you might be able to use these

http://www.google.nl/search?q=mplex+...utf-8&aq=t&rls
=o ...

though the following might work:
(?<var\[[^\]]) =
([0-9]+|[[^\]]|(sum|avg|count )\([0-9]+|[[^\]]\))([+/*-]([0-9]+|[[^\
]]
|(sum|?avg|c ount)\([0-9]+|[[^\]]\)))*
It does not take nested functions into account, nor does it allow
complex expressions inside a function (sum|avg|count) . You might be
able to get it working.
Good luck :)

--
Jesse Houwing
jesse.houwin g at sogeti.nl- Hide quoted text -
- Show quoted text -
Hi Jesse,

(?<var\[[^\]]) =
([0-9]+|[[^\]]|(sum|avg|count )\([0-9]+|[[^\]]\))([+/
*-]([0-9]+|[[^\]]|(sum|?avg|coun t)\([0-9]+|[[^\]]\)))*

(?<var\[[^\]]) is giving the error as invalid group name..
Seems I lost a in there

(?<var>\[[^\]])

And made a few errors on the way. I guess it happened when going from
one virtual pc to the next. I tested and expanded the expression and
this is what I ended up with:

\[[^\]]*\][ ]*=[ ]*([0-9]+|\[[^\]]*\]|(sum|avg|count )\([
]*([0-9]+|\[[^\]]*\])[ ]*\))([ ]*[-+*/][
]*([0-9]+|\[[^\]]*\]|(sum|avg|count )\([ ]*([0-9]+|\[[^\]]*\])[
]*\)))*

Tested this time ;)

--
Jesse Houwing
jesse.houwin g at sogeti.nl- Hide quoted text -
- Show quoted text -
Hi Jesse,

Thank you very much. It's working.
You;re very welcome :)
I Just made the following change:
^\[[a-zA-z]+([0-9])*\][ ]*=[ ]*([0-9]+|\[[a-zA-z]+([0-9])*\]|(sum|avg|
count)\([ ]*([0-9]+|\[[a-zA-z]+([0-9])*\])[
]*\))([ ]*[-+*/][ ]*([0-9]+|\[[a-zA-z]+([0-9])*\]|(sum|avg|count )\
([ ]*([0-9]+|\[[a-zA-z]+([0-9])*\])[
]*\)))*$
because, earlier it was taking space inside [ and ] like [current
charges].
It would accept anything between [] except a ]. :).
let's see together for further improvement of this :)
Keep me posted. I'm monitoring this group on a regular basis, if you include
the word regex it should light up automatically :).
--
Jesse Houwing
jesse.houwing at sogeti.nl
Nov 7 '07 #6
On Nov 7, 3:02 pm, Jesse Houwing <jesse.houw...@ newsgroup.nospa m>
wrote:
Hello venugopal.s...@ gmail.com,


On Nov 6, 4:51 pm, Jesse Houwing <jesse.houw...@ newsgroup.nospa m>
wrote:
Hello venugopal.s...@ gmail.com,
>On Nov 6, 2:53 pm, Jesse Houwing <jesse.houw...@ newsgroup.nospa m>
wrote:
>>Hello venugopal.s...@ gmail.com,
>>>Hi Friends,
>>>I'm constructing a regular expression for validating an expression
which looks as any of the following forms:
>>>1. [GrandTotal]=4*[TotalCharges]+[currentCharges]+2
OR
2. [TotalCharges]=Sum([CurrentCharges])*6
Some of the samples I have constructed below:
StringEx RegEx
[alphaNumeric] --->
^\[[a-zA-Z]+[0-9]*\]$
[TotalCharges]+2 --->
^\[[a-zA-Z]+[0-9]*\](\
+[0-9]*)*$
[TotalCharges]/22+5/6*8--->
^\[[a-zA-Z]+[0-9]*\]([\+\-\*\/][0-9]*)*$
[TotalCharges]/22+5/6*8+[currChrgs]
---->^\[[a-zA-Z]+[0-9]*\]([\+\-\*
\/][0-9]*)*([\+\-\*\/]\[[a-zA-Z]+[0-9]*\])*$
2*[TotalCharges]/22+5/6*8+[currChrgs]
----->^([0-9]*[\+\-\*\/])*\[[a-
zA-Z]+[0-9]*\]([\+\-\*\/][0-9]*)*([\+\-\*\/]\[[a-zA-Z]+[0-9]*\])*$
Pls help me... I'm badly in need of this in my project.
A parser would be a much better solutio than a regular expression.
Microsoft recently started shipping Mplex/MPPG with the Visual
Studio SDK, you might be able to use these
>>>http://www.google.nl/search?q=mplex+...utf-8&aq=t&rls
=o ...
>>though the following might work:
(?<var\[[^\]]) =
([0-9]+|[[^\]]|(sum|avg|count )\([0-9]+|[[^\]]\))([+/*-]([0-9]+|[[^\
]]
|(sum|?avg|co unt)\([0-9]+|[[^\]]\)))*
It does not take nested functions into account, nor does it allow
complex expressions inside a function (sum|avg|count) . You might be
able to get it working.
Good luck :)
>>--
Jesse Houwing
jesse.houwi ng at sogeti.nl- Hide quoted text -
- Show quoted text -
Hi Jesse,
>(?<var\[[^\]]) =
([0-9]+|[[^\]]|(sum|avg|count )\([0-9]+|[[^\]]\))([+/
*-]([0-9]+|[[^\]]|(sum|?avg|coun t)\([0-9]+|[[^\]]\)))*
>(?<var\[[^\]]) is giving the error as invalid group name..
Seems I lost a in there
(?<var>\[[^\]])
And made a few errors on the way. I guess it happened when going from
one virtual pc to the next. I tested and expanded the expression and
this is what I ended up with:
\[[^\]]*\][ ]*=[ ]*([0-9]+|\[[^\]]*\]|(sum|avg|count )\([
]*([0-9]+|\[[^\]]*\])[ ]*\))([ ]*[-+*/][
]*([0-9]+|\[[^\]]*\]|(sum|avg|count )\([ ]*([0-9]+|\[[^\]]*\])[
]*\)))*
Tested this time ;)
--
Jesse Houwing
jesse.houwing at sogeti.nl- Hide quoted text -
- Show quoted text -
Hi Jesse,
Thank you very much. It's working.

You;re very welcome :)
I Just made the following change:
^\[[a-zA-z]+([0-9])*\][ ]*=[ ]*([0-9]+|\[[a-zA-z]+([0-9])*\]|(sum|avg|
count)\([ ]*([0-9]+|\[[a-zA-z]+([0-9])*\])[
]*\))([ ]*[-+*/][ ]*([0-9]+|\[[a-zA-z]+([0-9])*\]|(sum|avg|count )\
([ ]*([0-9]+|\[[a-zA-z]+([0-9])*\])[
]*\)))*$
because, earlier it was taking space inside [ and ] like [current
charges].

It would accept anything between [] except a ]. :).
let's see together for further improvement of this :)

Keep me posted. I'm monitoring this group on a regular basis, if you include
the word regex it should light up automatically :).
--
Jesse Houwing
jesse.houwing at sogeti.nl- Hide quoted text -

- Show quoted text -
Hi Jesse,

The RegEx matches when we give whole numbers as in the expression
2+[jh] + 2 + 6 * [sssdsf323] + 2 * 3 + [dd] + 2 + [p] + SuM([ab]) * 9
+ AVG( [a] ).

I changed the RegEx as below to include decimal numbers as
[totalChrgs] + 2.3 * 5.67. The RegEx is as below.

^([0-9]+(\.\d{2})?|\[[a-zA-z]+([0-9])*\]|([Ss][Uu][Mm]|[Aa][Vv][Gg]|
[Cc][Oo][Uu][Nn][Tt])\([ ]*([0-9]+(\.\d{2})?|\[[a-zA-z]+([0-9])*\])[
]*\))([ ]*[-+*/][ ]*([0-9]+(\.\d{2})?|\[[a-zA-z]+([0-9])*\]|([Ss][Uu]
[Mm]|[Aa][Vv][Gg]|[Cc][Oo][Uu][Nn][Tt])\([ ]*([0-9]+(\.\d{2})?|\[[a-zA-
z]+([0-9])*\])[
]*\)))*$

But it is not matching with the expression. What could be the problem?

Reply soon,

Thanks and regards,
Venu

Nov 11 '07 #7
Hello Venu,

Hi Jesse,

The RegEx matches when we give whole numbers as in the expression 2+[jh]
+ 2 + 6 * [sssdsf323] + 2 * 3 + [dd] + 2 + [p] + SuM([ab]) * 9 + AVG( [a] ).
>
I changed the RegEx as below to include decimal numbers as [totalChrgs]
+ 2.3 * 5.67. The RegEx is as below.
>
^([0-9]+(\.\d{2})?|\[[a-zA-z]+([0-9])*\]|([Ss][Uu][Mm]|[Aa][Vv][Gg]|
[Cc][Oo][Uu][Nn][Tt])\([ ]*([0-9]+(\.\d{2})?|\[[a-zA-z]+([0-9])*\])[
]*\))([ ]*[-+*/][ ]*([0-9]+(\.\d{2})?|\[[a-zA-z]+([0-9])*\]|([Ss][Uu]
[Mm]|[Aa][Vv][Gg]|[Cc][Oo][Uu][Nn][Tt])\([ ]*([0-9]+(\.\d{2})?|\[[a-zA-
z]+([0-9])*\])[
]*\)))*$

But it is not matching with the expression. What could be the problem?

Reply soon,

Thanks and regards,
Venu
Change \.\d{2} in \.\d{1,} or \.\d{1,2} to allow one or more number(s) after
the decimal point. Currently the regex only matches if there are exactly
2 numbers after the point.

Also note that you can rewrite this:

Jesse

--
Jesse Houwing
jesse.houwing at sogeti.nl
Nov 11 '07 #8
Hello Venu,

Hi Jesse,

The RegEx matches when we give whole numbers as in the expression 2+[jh]
+ 2 + 6 * [sssdsf323] + 2 * 3 + [dd] + 2 + [p] + SuM([ab]) * 9 + AVG( [a] ).
>
I changed the RegEx as below to include decimal numbers as [totalChrgs]
+ 2.3 * 5.67. The RegEx is as below.
>
^([0-9]+(\.\d{2})?|\[[a-zA-z]+([0-9])*\]|([Ss][Uu][Mm]|[Aa][Vv][Gg]|
[Cc][Oo][Uu][Nn][Tt])\([ ]*([0-9]+(\.\d{2})?|\[[a-zA-z]+([0-9])*\])[
]*\))([ ]*[-+*/][ ]*([0-9]+(\.\d{2})?|\[[a-zA-z]+([0-9])*\]|([Ss][Uu]
[Mm]|[Aa][Vv][Gg]|[Cc][Oo][Uu][Nn][Tt])\([ ]*([0-9]+(\.\d{2})?|\[[a-zA-
z]+([0-9])*\])[
]*\)))*$

But it is not matching with the expression. What could be the problem?

Reply soon,

Thanks and regards,
Venu
Change \.\d{2} in \.\d{1,} or \.\d{1,2} to allow one or more number(s) after
the decimal point. Currently the regex only matches if there are exactly
2 numbers after the point.

Also consider rewriting \d as [0-9], I find it more readable and it's one
of the few times I make an exclusion to the rule mentioned below.

Also note that you can rewrite this:
[a-zA-z]+([0-9])*

as

[a-zA-z]+[0-9]* (I usually say that in case of a regex, shorter is better).
Jesse

--
Jesse Houwing
jesse.houwing at sogeti.nl
Nov 11 '07 #9
On Nov 12 2007, 12:15 am, Jesse Houwing
<jesse.houw...@ newsgroup.nospa mwrote:
Hello Venu,
Hi Jesse,
The RegEx matches when we give whole numbers as in the expression 2+[jh]

+ 2 + 6 * [sssdsf323] + 2 * 3 + [dd] + 2 + [p] + SuM([ab]) * 9 + AVG( [a] ).
I changed the RegEx as below to include decimal numbers as [totalChrgs]

+ 2.3 * 5.67. The RegEx is as below.
^([0-9]+(\.\d{2})?|\[[a-zA-z]+([0-9])*\]|([Ss][Uu][Mm]|[Aa][Vv][Gg]|
[Cc][Oo][Uu][Nn][Tt])\([ ]*([0-9]+(\.\d{2})?|\[[a-zA-z]+([0-9])*\])[
]*\))([ ]*[-+*/][ ]*([0-9]+(\.\d{2})?|\[[a-zA-z]+([0-9])*\]|([Ss][Uu]
[Mm]|[Aa][Vv][Gg]|[Cc][Oo][Uu][Nn][Tt])\([ ]*([0-9]+(\.\d{2})?|\[[a-zA-
z]+([0-9])*\])[
]*\)))*$
But it is not matching with the expression. What could be the problem?
Reply soon,
Thanks and regards,
Venu

Change \.\d{2} in \.\d{1,} or \.\d{1,2} to allow one or more number(s) after
the decimal point. Currently the regex only matches if there are exactly
2 numbers after the point.

Also consider rewriting \d as [0-9], I find it more readable and it's one
of the few times I make an exclusion to the rule mentioned below.

Also note that you can rewrite this:
[a-zA-z]+([0-9])*

as

[a-zA-z]+[0-9]* (I usually say that in case of a regex, shorter is better).

Jesse

--
Jesse Houwing
jesse.houwing at sogeti.nl
Hi Jesse, how are you doing?
How can we incorporate an expression like this in our regular
expression?
((([col1]+[col2])*[col3])/5)

Thanks,
Venu
Jan 10 '08 #10

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

Similar topics

6
2022
by: paulsmith5 | last post by:
Hi, I have the following regular expression to validate a date-time field in European or d/m/y h:m:s format. ^((((31\/(0?|1))|((29|30)\/(0?|1)))\/(1|\d)?\d{2})|(29\/0?2\/(((1|\d)?(0||)|((16||)00))))|(0?|1\d|2)\/((0?)|(1))\/((1|\d)?\d{2})) (20|21|22|23|?\d):?\d:?\d$ I wish to ammend it so that the time or h:m:s part is validated only if supplied (i.e. I wish to make the time part optional). At present if a
8
7316
by: Rajeev Soni | last post by:
Hi I am looking for the regular expression for validating the allowed file types to upload like files like "zip,pdf,doc,rtf,gif,jpg,png,txt"; and the expression should not be case sensitive like it must match ZIP | zip | zIp..... regards rajeev
3
2212
by: Mark | last post by:
To validate the length of a multiline textbox, I'm told that I have to use a regular expression validator. The regular expression below limits it to 25 characters in length, but if the user enters a hard return, it bombs regardless of length. How do you allow hard returns in the following regular expression? Thanks in advance! ^.{0,25}$ Mark
18
3026
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How ??
14
11432
by: olekristianvillabo | last post by:
I have a regular expression that is approximately 100k bytes. (It is basically a list of all known norwegian postal numbers and the corresponding place with | in between. I know this is not the intended use for regular expressions, but it should nonetheless work. the pattern is ur'(N-|NO-)?(5259 HJELLESTAD|4026 STAVANGER|4027 STAVANGER........|8305 SVOLVÆR)' The error message I get is:
7
12940
by: Tizzah | last post by:
What is wrong with that? regex = /^(http|https):\/\/+({1}+)*\.{2,5}(({1,5})?\/.*)?$/ if(field.hpage.value != regex.test(field.hpage.value)){ alert("Bad Homepage") field.hpage.focus() field.hpage.select() return false
1
2572
by: durga2005 | last post by:
hi I m validating a textbox using regular expression validator and these controls are placed inside the update panel the validation is not working inside update panel
1
5843
by: durga2005 | last post by:
hi i have a textbox and regular expression validator control .i have placed these control inside update panel. just im validating the textbox with regular expression validator control when i enter wrong data in the text box ,it is not showing error.only after i click the button it is showing the error message. before placing these controls in update panel,the validation was working
7
1856
by: graphicsxp | last post by:
Hi, I can't figure out what the regular expression would look like for validating a string such as : Lastname, Firstname I could only come up with /\w/ which doesn't check for the comma. Can someone help ?
0
8392
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8823
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8730
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6163
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1950
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1607
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.