Hi All,
I need a regular expression to be used in an ASP page which would
allow a user to enter:
1000 as well as
1,000
i.e. an amount without comma as well as with comma(for example 10,000
or 100,000 etc.)
If anyone's aware, please let me know. I am in urgent need to use it.
Thanks and Regards,
Ankur 7 4403
Ankur,
Do you have to use a regular expression here? It seems like you have to
use a number, so why not use the TryParse method on the Int32 class? You
can set it to recognize thousands separators, or skip them (using the
NumberFormatInf o class) and then go from there.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
<he********@gma il.comwrote in message
news:11******** **************@ l77g2000hsb.goo glegroups.com.. .
Hi All,
I need a regular expression to be used in an ASP page which would
allow a user to enter:
1000 as well as
1,000
i.e. an amount without comma as well as with comma(for example 10,000
or 100,000 etc.)
If anyone's aware, please let me know. I am in urgent need to use it.
Thanks and Regards,
Ankur
Hi,
The ugliest code ever:
try
{
double d = Convert.toDoubl e( mycurvalue.Repl ace( "$", "").Replace (
",","") );
}
Hope you like it :)
<he********@gma il.comwrote in message
news:11******** **************@ l77g2000hsb.goo glegroups.com.. .
Hi All,
I need a regular expression to be used in an ASP page which would
allow a user to enter:
1000 as well as
1,000
i.e. an amount without comma as well as with comma(for example 10,000
or 100,000 etc.)
If anyone's aware, please let me know. I am in urgent need to use it.
Thanks and Regards,
Ankur
On Mar 30, 1:17 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guar d.caspershouse. comwrote:
Ankur,
Do you have to use a regular expression here? It seems like you have to
use a number, so why not use the TryParse method on the Int32 class? You
can set it to recognize thousands separators, or skip them (using the
NumberFormatInf o class) and then go from there.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard .caspershouse.c om
<hellben...@gma il.comwrote in message
news:11******** **************@ l77g2000hsb.goo glegroups.com.. .
Hi All,
I need a regular expression to be used in an ASP page which would
allow a user to enter:
1000 as well as
1,000
i.e. an amount without comma as well as with comma(for example 10,000
or 100,000 etc.)
If anyone's aware, please let me know. I am in urgent need to use it.
Thanks and Regards,
Ankur- Hide quoted text -
- Show quoted text -
Hi again,
Thanks for your response. But I actually need to use regular
expression on aspx page itself so that the user if wishes to enter an
amount with thousand separator, he is allowed to do so. Also the
simple form(not having commas). Please help me with this if you can.
Regards,
Ankur
Thanks for your response. But I actually need to use regular
expression on aspx page itself so that the user if wishes to enter an
amount with thousand separator, he is allowed to do so. Also the
simple form(not having commas). Please help me with this if you can.
And if you will have to localize your web site, or accept money from outside
US, you will run into troubles (because the decimal separator is comma in
most of Europe). TryParse is the safest option.
--
Mihai Nita [Microsoft MVP, Windows - SDK] http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
<he********@gma il.comwrote in message
news:11******** **************@ l77g2000hsb.goo glegroups.com.. .
Hi All,
I need a regular expression to be used in an ASP page which would
allow a user to enter:
1000 as well as
1,000
i.e. an amount without comma as well as with comma(for example 10,000
or 100,000 etc.)
Something like:
[0-9]+(,[0-9]{3})*
As others have said, this is only good with the (American? Imperial?)
notation using comma for thousands grouping and point as decimal separator.
>
If anyone's aware, please let me know. I am in urgent need to use it.
Thanks and Regards,
Ankur
On Mar 30, 8:59 pm, "Ben Voigt" <r...@nospam.no spamwrote:
<hellben...@gma il.comwrote in message
news:11******** **************@ l77g2000hsb.goo glegroups.com.. .
Hi All,
I need aregularexpress ionto be used in an ASP page which would
allow a user to enter:
1000 as well as
1,000
i.e. an amount without comma as well as with comma(for example 10,000
or 100,000 etc.)
Something like:
[0-9]+(,[0-9]{3})*
As others have said, this is only good with the (American? Imperial?)
notation using comma for thousands grouping and point as decimal separator.
If anyone's aware, please let me know. I am in urgent need to use it.
Thanks and Regards,
Ankur- Hide quoted text -
- Show quoted text -
Hi Ben,
I tried your regular expression. It worked for most of the cases. But
in addition to all, it also accepts 1000,000 which it should not have.
Instead 1,000,000 is what should have been allowed. Any minor change
that can be done to the reg-ex you provided??
Secondly, I never posted my efforts on this thread. Here's what I have
been trying my hands on :
((\d{1,3})(\,\d {3})*)|(\d\d*)) ((\.\d{2})?)
It's an OR of two reg-ex, first one being the reg-ex to recognise the
number with thousand separator and second without thousand separator.
The pipe "|" doesn't seem to OR the two conditions. Any idea why is
this happening?
Hoping to get some headway..
Regards,
Ankur
Try the following:
\b(?:\d{1,3}(?( ?=[,.])[,.](?:\d{3}(?:[.,](?=\d)|\b)|(?:\ b|\d{1,2}))|\b) )+
It's a bit complicated to explain, but I'll try.
First, it asserts that the match must begin on a word boundary. The match
follows as a non-capturing group which may be repeated any number of times.
The match consists of:
1. 1-3 digits
2. These digits may be followed by a period or comma.
a. If they are followed by a period or a comma, they are followed by
either:
aa. Exactly 3 digits followed by a period or comma that must be
followed by a (not captured) digit, or
bb. a word boundary
b. Otherwise (not followed by a period or comma) either
aa. 1 or 2 digits, or
bb. a word boundary
3. If the initial 1-3 digits are NOT followed by a period or comma, they
must
be followed by a word boundary.
So, essentially, the rules expressed are that a match consists of a sequence
of 1-3 digits with commas between the groups of digits. However, if a group
of digits is surrounded by periods or commas, there must be exactly 3.
The trick is the quantifier on the entire group. This creates a repeating
pattern of groups of 1-3 digits followed by periods or commas. However, the
last group of digits must be followed by a word boundary, and the first
group must be preceded by a word boundary. And if a group of digits is
between periods/commas, there must be exactly 3.
--
HTH,
Kevin Spencer
Microsoft MVP
Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries: http://www.miradyne.net
<he********@gma il.comwrote in message
news:11******** **************@ l77g2000hsb.goo glegroups.com.. .
On Mar 30, 8:59 pm, "Ben Voigt" <r...@nospam.no spamwrote:
><hellben...@gm ail.comwrote in message
news:11******* *************** @l77g2000hsb.go oglegroups.com. ..
Hi All,
I need aregularexpress ionto be used in an ASP page which would
allow a user to enter:
1000 as well as
1,000
i.e. an amount without comma as well as with comma(for example 10,000
or 100,000 etc.)
Something like:
[0-9]+(,[0-9]{3})*
As others have said, this is only good with the (American? Imperial?) notation using comma for thousands grouping and point as decimal separator.
If anyone's aware, please let me know. I am in urgent need to use it.
Thanks and Regards,
Ankur- Hide quoted text -
- Show quoted text -
Hi Ben,
I tried your regular expression. It worked for most of the cases. But
in addition to all, it also accepts 1000,000 which it should not have.
Instead 1,000,000 is what should have been allowed. Any minor change
that can be done to the reg-ex you provided??
Secondly, I never posted my efforts on this thread. Here's what I have
been trying my hands on :
((\d{1,3})(\,\d {3})*)|(\d\d*)) ((\.\d{2})?)
It's an OR of two reg-ex, first one being the reg-ex to recognise the
number with thousand separator and second without thousand separator.
The pipe "|" doesn't seem to OR the two conditions. Any idea why is
this happening?
Hoping to get some headway..
Regards,
Ankur This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
testMyColumn{1, 100}Test
Basically I want the regular expression to add the word test infront of the
|
by: Ken McAndrew |
last post by:
I am trying to write a regular expression to cover US currency, where the
dollar sign and cents are optional. The following string worked when I used
it in the ValidationExpression field of a RegularExpressionValidator
control:
?\d{1,10}(\d{2})?
However, when I tried to make a function using this expression, it would not
validate properly, allowing as many numbers after the decimal point as
desired, and also allowing more than 10...
|
by: George Durzi |
last post by:
If I have a regexvalidator in a webform with a validation expression of
^?\d* and I put the text 2d in a text box being validated by this
validator, the validator fires.
This regex is a simple one that only allows the user to enter integer
values.
However, if I do this on the server side like this
Regex rx = new Regex(@"^?\d*");
|
by: Sreedhar Vankayala |
last post by:
Hi,
I have a simple textbox in a form page.
- If data not available, then user can enter the text "Not available"
or "Contact abc person".
- If data is available, then user enters the data in currency.
Given both conditions, how do I validate both scenarios. What is the
|
by: Billa |
last post by:
Hi,
I am replaceing a big string using different regular expressions (see
some example at the end of the message). The problem is whenever I
apply a "replace" it makes a new copy of string and I want to avoid
that. My question here is if there is a way to pass either a memory
stream or array of "find", "replace" expressions or any other way to
avoid multiple copies of a string.
Any help will be highly appreciated
| |
by: Mike |
last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in
matches. I would like to get what the actual regular expression is.
In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART (CONDUCTION
DEFECT) 37.33/2 HEART (CONDUCTION DEFECT) WITH
CATHETER 37.34/2 " the expression is "HEART (CONDUCTION DEFECT)". How
do I gain access to the expression (not the matches) at runtime?
Thanks,
Mike
|
by: Mike9900 |
last post by:
Hello,
I need a regular expression to match a currency with its symbol, for example
Pound66.99 must return 66.99 or Pound(66.99) or Pound-66.99 or -66.99Pound
return -66.99 or any other combination return the decimal number.
I have created a regular expression, but it seems that it does not work if
the number is Pound66.99 but it works if the sign is after the number:
public static Decimal ConvertToDecimal(String str)
|
by: Dilip |
last post by:
I am using the .NET regular expressions library to match anything that
resembles a price/amount (33.33, 225.44 etc) out of a stream. I have
this pattern with me currently:
\d+(\.\d*)?
This doesn't match the string as one full word. IOW, I want the regex
to match a dollar amount in its entirety (any number of digits before
the decimal point but only 2 digits after the decimal). I am a total
newbie to Regex and the best I came up...
|
by: Gulnarambi |
last post by:
I have a form in datasheet view with Total and Currency text boxes, in Currency text box I only can enter values of AZN and USD.
Form is based on Table and as criterias information fromUnbound control from another form is used,
In form footer I need to create too text boxes, one of then shoul calculate sum of Total for records where currency field equals to USD and other one calculates sum for Total for records where Currency field equals to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
| |
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |