Regular Expressions: Positive Lookahead and Word Border question
- by Inf.S
Hello again Stackoverflow people!
Assume I have these words: smartphones, smartphone
I want to match the substring "phone" from within them. However, in both case, I want only "phone" to be returned, not "phones" in the first case. In addition to this, I want matches only if the word "phone" is a suffix only, such that:
fonephonetics (just an example) is not matched.
I assumed that the regex
(phone([?=s])?)\b
would give me what I need, but it is currently matching "phones" and "phone", but not the "fonephonetics" one. I don't need "phones". I want "phone" for both cases.
Any ideas about what is wrong, and what I can do?
Thank you in advance!