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

    Join Date
    Aug 2013
    Posts
    10
    Rep Power
    0

    Question Delete words according to a list of words


    Hi, starting from a string i need to re-elaborate it deleting words that are unnecessary.

    The string may have only one or more than one of those words. I want insert those words directly into the RegEx code, but what is right the syntax to use?

    For exemple, some of the words that i want to delete are "of", "I", "finding", "want", "one", "two", and all numbers.

    So, a string og genere: "I want chocolate", should become "chocolate"
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    spaceBAR Central
    Posts
    229
    Rep Power
    42
    Post some example data of what the lines look like before any change and what you want them to look like afterwards.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    10
    Rep Power
    0

    Arrow


    "150 dogs" -> "dogs"
    "searching for a woman" -> "woman"
    "flames and shadows" -> "flames shadows"
    "i like the blu color" -> "blu color"
    "i love to surf" -> "surf"

    ...

    Actually i've created an array with all "blacklisted" words, and with a loop i proceed to delete it from the original string, but i think that for this operation is better to use regex.
    So i wanna place all the "blacklisted" words directly in the regex syntax, and delete it when matched (in my case, i will use str_replace of PHP)
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    spaceBAR Central
    Posts
    229
    Rep Power
    42

IMN logo majestic logo threadwatch logo seochat tools logo