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

    Join Date
    Oct 2016
    Posts
    3
    Rep Power
    0

    Whole words except email


    Can anyone help? I have a string that I want the words "company" matched expect if it is part of an email. (or I suppose has a @ or any other
    character in front of it.

    I already have
    Code:
    \b(?:(\w*company))\b
    example text is

    to contact the company email the company at info @ company.com

    thanks in advance
  2. #2
  3. Forgotten Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,025
    Rep Power
    9616
    \b is just a word boundary - meaning there's a word character on one site and a non-word character on the other. How about being more specific and requiring whitespace before the word?
    Code:
    (?<=\s)company\b
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2016
    Posts
    3
    Rep Power
    0
    thanks for reply but I couldn't get that to work - the top regex already works except I don't want it to match the @company

    thanks
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2016
    Posts
    3
    Rep Power
    0
    I managed to sort it using the following

    Code:
    \bcompany\b(?!\s{2}|\S)

IMN logo majestic logo threadwatch logo seochat tools logo