M
M
Michael Kim2015-11-01 18:21:00
Regular Expressions
Michael Kim, 2015-11-01 18:21:00

How to exclude words containing a specific string?

There is such a regular expression:
/([Mm]ir[a-z]{1,3})/u
It will find 3 matches in the line: "World by world by worlds" and everything works, but in the line "World by world by worlds" it will find 4 matches, since the word "humble" fits the pattern, what should be added to it so that the word "humble" and the like do not fit the pattern?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Inchin ☢, 2015-11-01
@Marox

Firstly, there is a case-insensitive search (flag i), and secondly, a character \bis a word boundary.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question