regex - How to match words with common prefix in PHP? -
i need write regex match word. find exact word can done using /\bword\b/ pattern.
but want pattern find word, words, wording , on.
for example want write pattern find terms account, accounting, accounts , accountant in paragraph string.
to match keyword optionally followed s, ing, ant, can use:
/\b($word(?:|s|ing|ant))\b/i if want allow optional letters suffix can use:
/\b($word\w*)\b/i
Comments
Post a Comment