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

    Join Date
    Jul 2007
    Posts
    4
    Rep Power
    0

    Help with regular expression


    Hi
    i'm trying to build a regular expression that will look for a specific combination of strings but must not include a specific combination, and i'm having problems
    what i need is to find all strings that:
    1. contain the phrase "*contain*love*" (meaning, the sentence "contain love" is good, the sentence "contain big love" is good, the sentence "must contain great love" is good, the sentence "might contain very big love indeed" is good, etc.) - this part is easy and i don't have an issue with it.
    2. DO NOT contain the exact combination "love child" (meaning, the sentence "might contain very big love sick child" is ok, but the sentence "might contain very big live child today" should not match - this is where i'm stumped

    can anyone help ?
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,068
    Rep Power
    9398
    Code:
    1. \bcontain\b.*\blove\b
    ("contain" as a word, then stuff, then "love" as a word)

    For #2 do the same thing but check that the expression did not match. In regular expressions it's a lot easier to try to match something that exists than something that doesn't exist.
  4. #3
  5. Turn left at the third duck
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Location
    Nelson, NZ
    Posts
    112
    Rep Power
    93
    Hi Sambuv,
    Please don't cross-post.

    I replied on the other thread this morning.

IMN logo majestic logo threadwatch logo seochat tools logo