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

    Join Date
    Sep 2002
    Location
    Seattle, U.S.A.
    Posts
    712
    Rep Power
    13

    Match random string except for these groupings


    I'm trying to write a regex that would allow me to match a random string as long as it doesn't match a set of words, e.g.

    match:

    aeFEU
    vzFE
    zFvEG

    But not match a specific set of strings that begin with

    user
    login
    settings

    so further permutations would not be matched:
    user/mark
    settings/privacy/2
    etc.



    I tried something like

    /[a-zA-Z]*[^{user*|login*|settings*}]/

    Which sorta works, but user/mark does match ...

    TIA
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    If your language supports negative matches (like grep -v) then you can just write one that matches what you DON'T want, and negate it.

    -Dan
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2002
    Location
    Seattle, U.S.A.
    Posts
    712
    Rep Power
    13
    Originally Posted by ManiacDan
    If your language supports negative matches (like grep -v) then you can just write one that matches what you DON'T want, and negate it.

    -Dan
    Thanks I'll give that a go

IMN logo majestic logo threadwatch logo seochat tools logo