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 

see it

if want allow optional letters suffix can use:

/\b($word\w*)\b/i 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -