Regex help for removing common words except those in quotes
Posted: Mon Nov 11, 2013 4:59 am
I've got this regular expression below which removes common whole words($commonWords) from a string($input) an I would like to tweak it so that
1. it ignores those words (more than one word) in double or single quotes (like exact search in google search tab)
2. it remove words starting with hyphen ('-') but not those inside double or single quotes (like negative search in google search tab)
return preg_replace('/\b('.implode('|',$commonWords).')\b/i','',$input);
thanks
1. it ignores those words (more than one word) in double or single quotes (like exact search in google search tab)
2. it remove words starting with hyphen ('-') but not those inside double or single quotes (like negative search in google search tab)
return preg_replace('/\b('.implode('|',$commonWords).')\b/i','',$input);
thanks