I need to write a regex to match the word. To find exact word can be done using /\bword\b/ pattern.
But I want the pattern to find word, words, wording and so on.
for example i want to write a pattern to find terms account, accounting, accounts and accountant in a paragraph string.
To just match your keyword optionally followed by s, ing, ant, you can use:
/\b($word(?:|s|ing|ant))\b/i
see it
If you want to allow any optional letters as suffix you can use:
/\b($word\w*)\b/i
I think this gets you there:
/\<word(|s|ing)\>/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With