Results 1 to 5 of 5

Thread: Regular Expression: Non negative real

  1. #1

    Thread Starter
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Regular Expression: Non negative real

    I'm stumped.

    Can anyone give me the regular expression for testing a string to see if it's a non negative real?

    ie

    0.000 F
    0.001 T
    0.101 T
    1.000 T
    1.111 T

    There is no fixed length to the decimal part, either.

    Many thanks,

    M
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

  2. #2
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: Regular Expression: Non negative real

    If csng(field) > 0 then
    endif
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  3. #3

    Thread Starter
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Re: Regular Expression: Non negative real

    Quote Originally Posted by Pasvorto
    If csng(field) > 0 then
    endif
    Thanks for the quick reply, but that's not a regular expression.

    For instance, a non-negative integer can be matched using '^-{0}[0-9]+$' which denotes the set of integers 0,1,2,3,4 . . .n
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Regular Expression: Non negative real

    Just add a decimal point and any number of integers, in that order, to the right end. I'm a bit rusty at Regex, but I think it would be ^-{0}d+\.d+$
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  5. #5

    Thread Starter
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Re: Regular Expression: Non negative real

    Thanks.

    The '^-{0}\d+\.\d+$' expression does evaluate reals, but does not exclude 0.0
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width