I have a regex expression that I'm using to find all the words in a given block of content, case insensitive, that are contained in a glossary stored in a database. Here's my pattern:
/($word)/i
The problem is, if I use /(Foo)/i
then words like Food
get matched. There needs to be whitespace or a word boundary on both sides of the word.
How can I modify my expression to match only the word Foo
when it is a word at the beginning, middle, or end of a sentence?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…