#1
  1. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2004
    Location
    Hampshire, UK
    Posts
    990
    Rep Power
    315

    Capture number NOT starting with a decimal point


    Hi all,

    I have been trying to write an expression which captures numbers... easy enough - but here's the catch, i only want to capture numbers which don't start with "." so:

    hello 1 world = 1
    hello 1.2 world = 1.2
    hello .2 world = no match
    hello .1.2 = 1.2

    All my attempts have matched all of the above which isn't what i want!

    Im not entirely sure but do i need to use backreferences here? I have looked around online but nothing seems to help.

    Im going crazy over this... any help would be much appreciated.

    Thanks
    Scott Perham, BSc (hons), CCNA, MCPD
  2. #2
  3. No Profile Picture
    User 165270
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2005
    Posts
    497
    Rep Power
    938
    Try:

    Code:
    \d+\.\d+|(?<!\.)\d

    Comments on this post

    • ManiacDan agrees

IMN logo majestic logo threadwatch logo seochat tools logo