Click here to Skip to main content
15,892,005 members
Home / Discussions / C#
   

C#

 
AnswerRe: object-access question Pin
NaNg1524112-May-06 6:15
NaNg1524112-May-06 6:15 
AnswerRe: object-access question Pin
Stefan Troschuetz12-May-06 6:32
Stefan Troschuetz12-May-06 6:32 
AnswerRe: object-access question Pin
spin vector12-May-06 6:40
spin vector12-May-06 6:40 
QuestionIE Component Pin
mehrdadc4812-May-06 5:43
mehrdadc4812-May-06 5:43 
AnswerRe: IE Component Pin
led mike12-May-06 5:51
led mike12-May-06 5:51 
Questionrecording sound stream Pin
Naveed Kamboh12-May-06 5:17
Naveed Kamboh12-May-06 5:17 
QuestionHow to add Virtual Printer (vs 2003) Pin
Rizwan Bashir12-May-06 5:05
Rizwan Bashir12-May-06 5:05 
Questioncombining subexpressions into 1 Regex expression Pin
theFrenchHornet12-May-06 5:04
theFrenchHornet12-May-06 5:04 
I want to check for a decimal number where one or more digits are allowed before the decimal point (in which case digits after the decimal point are optional) or one or more characters are allowed after the decimal point (in which case digits before the decimal point are optional). The decimal point is optional, but you cannot have just the decimal point.
e.g. 1.3, 1., .1 all ok.
. not ok.

The pattern @"^\d+\.?\d*$" takes care of the case where there are digits before the decimal point.

The pattern @"^\d*\.?\d+$" takes care of the case where there are digits after the decimal point.

Either one by itself is not sufficient.

I thought I could combine them to have an either/or expression the way you would have [a|n] to say either 'a' or 'n', by making them subexpressions like this:
@"[(^\d+\.?\d*$) | (\d*\.?\d+$)]"

It doesn't work, though. This matches on each digit and the decimal point. e.g., 30.5 give 4 matches - '3', '0', '.', '5'.

I can achieve what I want in other ways, but wondering if someone can tell me if there is a regular expression to do what I want and/or explain why the last pattern matches on each digit - I'm not seeing it.

Thanks.
Questiona question about contextmenustrip ? Pin
cmpeng3412-May-06 4:56
cmpeng3412-May-06 4:56 
AnswerRe: a question about contextmenustrip ? Pin
NaNg1524112-May-06 5:35
NaNg1524112-May-06 5:35 
QuestionHow to Exit Nested Methods Pin
#coder0512-May-06 4:53
#coder0512-May-06 4:53 
AnswerRe: How to Exit Nested Methods Pin
DigitalKing12-May-06 5:22
DigitalKing12-May-06 5:22 
AnswerRe: How to Exit Nested Methods Pin
RicoH12-May-06 5:28
RicoH12-May-06 5:28 
QuestionDirectX.Capture vs MVR 1000sx Pin
zoooooooooooooooooz12-May-06 4:52
zoooooooooooooooooz12-May-06 4:52 
AnswerRe: DirectX.Capture vs MVR 1000sx Pin
Dave Kreskowiak12-May-06 6:20
mveDave Kreskowiak12-May-06 6:20 
QuestionDateTime to excel date integer Pin
spin vector12-May-06 4:46
spin vector12-May-06 4:46 
AnswerRe: DateTime to excel date integer Pin
Guffa12-May-06 4:50
Guffa12-May-06 4:50 
GeneralRe: DateTime to excel date integer Pin
spin vector12-May-06 4:56
spin vector12-May-06 4:56 
QuestionControl Collection - Tabs Pin
JohnnyBoyWonder12-May-06 3:34
JohnnyBoyWonder12-May-06 3:34 
AnswerRe: Control Collection - Tabs Pin
NaNg1524112-May-06 3:48
NaNg1524112-May-06 3:48 
Questionlooking for good training material Pin
JonEngle12-May-06 3:06
JonEngle12-May-06 3:06 
AnswerRe: looking for good training material Pin
NaNg1524112-May-06 3:20
NaNg1524112-May-06 3:20 
QuestionWMI + Memory leak Pin
g00fyman12-May-06 3:00
g00fyman12-May-06 3:00 
QuestionProblems with using controls Pin
martinz081512-May-06 2:49
martinz081512-May-06 2:49 
Questionbroswer compatibility problem Pin
Parvathivadde12-May-06 2:09
Parvathivadde12-May-06 2:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.