#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    233
    Rep Power
    76

    File extension -- a period and then only letters and numbers


    Hello, I am trying to validate a file extension with regex.

    This is what I have
    Code:
    "^.\w\w*$"
    But the problem is if you type two or more letters/numbers with no period it will match. Its suppsoed to have the period in front :/
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,295
    Rep Power
    9400
    Like how \w matches a letter, number, or underscore, a . matches any character. It's a "metacharacter".

    If you want to use its literal meaning then stick a backslash in front.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    233
    Rep Power
    76
    oh cool thanks

IMN logo majestic logo threadwatch logo seochat tools logo