The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Regexes.... by MrTrick2006-03-30 19:09:23
  You could do it in 2 steps... by whybird2006-03-30 19:14:37
    Okay, assuming that it's already known to be a num by MrTrick2006-03-30 19:28:18
      I'm not the best regexer in the world by whybird 2006-03-30 20:37:48
but I came up with this rather convoluted expression: [0*.[[00[1-9]]|[0[1-9]0?]|[[1-9]0?0?]]]|[0*[1-9]+.[[[0-9][0-9][0-9]]|[ [0-9][0-9]]|[0-9]]]|[0*[1-9].?]

unfortunately, it doesn't work in my test.. but the OR code "|" is known to work differently in different implementations.

Here's a breakdown of my expression - I'd love some feedback from more experienced regexers!

[0*.   -- zero or more zeros, followed by a decimal point, followed by...
 [
  [00[1-9]] -- zero, zero and another digit
  | -- or
  [0[1-9]0?] -- zero, another digit, and an optional zero
  | -- or
  [[1-9]0?0?] -- a non-zero, followed by up to 2 optional zeros
 ]
]
| -- OR
[0*[1-9]+. -- zero or more zeros, 1 or more non-zeros, a decimal and ...
 [
  [[0-9][0-9][0-9]] -- 3 digits
  | -- or
  [[0-9][0-9]] -- 2 digits
  | -- or
  [0-9] -- 1 digit
 ]
]
| -- OR
[0*[1-9].?] -- zero or more zeros, a non-zero digit, and an optional decimal


I think my problem is the way I use the brackets to define the scope of the ORs?
[ Reply ]
        Aha! A working version! by whybird2006-03-30 21:14:34
          Specifically... by whybird2006-03-30 21:19:43
            Note that by whybird2006-03-30 22:11:08
              Grrr - really final version. I mean it this time by whybird2006-03-30 22:27:30

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)