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

    Join Date
    Jan 2014
    Posts
    1
    Rep Power
    0

    LINUX regexp for machine name


    need a regexp to check machine name

    first 3 character is alphabet (lower and upper both) then any alphanumeric if present.

    e.g
    Asd
    AWE1
    rTrP

    I have tried this '^[a-zA-Z]{3}[a-zA-Z0-9]*' its working fine with javascript but with Linux its allowing space and other character

    echo Xght | egrep '^[a-zA-Z]{3}[a-zA-Z0-9]*'
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,294
    Rep Power
    9400
    Your expression says is that it starts with 3 letters and then has another letter or number, but doesn't say anything about what can come after it. Throw in a end-of-line $ anchor so that there can't be anything after the four characters.

IMN logo majestic logo threadwatch logo seochat tools logo