Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET1.1 C# ASP.NET , +
Hi all,
 
I want to use a regular expression statement in my asp.net 1.1 project to validate float numbers which can have ", . " as floating seperators. I am new in this topic, please help me.
 
Thanks in advance.
Posted 15-Nov-12 22:40pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

try:
[+-]?\d+([\.\,]\d+)
  Permalink  
Comments
kurtiniadiss at 16-Nov-12 5:54am
   
Thank you very much OriginalGriff it works perfectly for floating point numbers, but there is one more problem. I want integers to be included in this control, I forgot to add them into the question :(
Milind Thakkar at 16-Nov-12 5:55am
   
This regex should work for int as well. Did you try?
OriginalGriff at 16-Nov-12 6:01am
   
Um - it won't! :laugh:
Milind Thakkar at 16-Nov-12 6:02am
   
:-( . Yup requires ? or probably * will also do, right?
OriginalGriff at 16-Nov-12 6:48am
   
? - Yes.
* - No.
"*" would allow 1.2,2.2.2,2
OriginalGriff at 16-Nov-12 6:00am
   
Add a question mark to the end: that makes the last part optional with zero or one repetitions:
[+-]?\d+([\.\,]\d+)?
kurtiniadiss at 16-Nov-12 6:23am
   
excellent! thank you so much:)
OriginalGriff at 16-Nov-12 6:48am
   
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 225
1 OriginalGriff 205
2 Manfred R. Bihy 190
3 CHill60 180
4 Sergey Alexandrovich Kryukov 164
0 OriginalGriff 7,395
1 Sergey Alexandrovich Kryukov 6,163
2 Maciej Los 3,754
3 Peter Leow 3,448
4 CHill60 2,702


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 16 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100