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

    Join Date
    Oct 2003
    Posts
    595
    Rep Power
    0

    Basic regex help needed


    Hi,

    I am using 'Edit Plus 'directory search option. I don't know much about Regex
    I need to write regex which gives me when ever there is word yahoo.com and hotmail.com but not @hotmail.com

    How can I do that in all one expression, Like you do pipe in unix
    web developer
  2. #2
  3. garish grotesque gargoyle
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2006
    Location
    gracing gargantuan gothic gateways
    Posts
    1,337
    Rep Power
    1037
    Code:
    /(yahoo\.com|[^@]*hotmail\.com)/

    would be containing yahoo.com or hotmail.com but not @hotmail.com

    would also match @yahoo.com

    the | operator says 'or'; if you put the whole phrase in a match condition (the () operators) then it's one phrase or the other. the [^something] syntax says 'not any character in these []'. the * operator says '0 or more', so that if the string starts with hotmail.com it will still match.

    try checking the other threads in the regex forum for some really helpful info about using regex in general, it will teach you a lot about the syntax and how to use it. good luck!

    "Human history becomes more and more a race between education and catastrophe." (H.G. Wells)
    "Giving me a new idea is like handing a cretin a loaded gun, but I do thank you anyhow, bang, bang." (Philip K. D!ck)
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2003
    Posts
    595
    Rep Power
    0
    Thanks for your help, I tested, it did not work, I put that regular expression in editPlus find box. I was searching a simple file that had yahoo.com and hotmail.com but I got the message "Can not find string" I am attachimng the snapshot
    Attached Images
    web developer
  6. #4
  7. No Profile Picture
    I haz teh codez!
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2003
    Posts
    2,547
    Rep Power
    2337
    Try
    Code:
    (yahoo\.com|[^@]hotmail\.com)
    I ♥ ManiacDan & requinix

    This is a sig, and not necessarily a comment on the OP:
    Please don't be a help vampire!

IMN logo majestic logo threadwatch logo seochat tools logo