How to make preg_match to find whole word but not separate hyphen-words?
问题 if (preg_match('#\b'.$rawword.'\b#i',$body)) { This code finds whole words, but if they are a hyphen word like "ABLE-BODIED" it will find ABLE and BODIED separately. How can modify the expression to accommodate for the dash? 回答1: You can use lookbehind and lookahead operators. This operators looks in behind and after but not match them. for example use \b(?<!-)xyz(?!-)\b for finding whole words of xyz that doesn't have - before or after. 来源: https://stackoverflow.com/questions/5781451/how-to