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 whybird2006-03-30 20:37:48
        Aha! A working version! by whybird2006-03-30 21:14:34
          Specifically... by whybird2006-03-30 21:19:43
            Note that by whybird 2006-03-30 22:11:08
it doesn't even assume they are all numbers.. you can just use this as the replacement for your original regex.

Numbers with extra trailing decimal places will be truncated. e.g. with input 1.234567, 1.234 will be found, and the trailing decimals ignored. Also, register 2 will reliably give the part after the decimal if there is any.

Aw, carp. I just noticed that you need to add another 0* in the last line:
(0*[1-9]0*\.?)>
otherwise whole numbers ending in zero will only match up to the last non-zero.

I'm pretty proud of myself here... *shiff* isn't anyone else going to even notice?
[ Reply ]
              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.)