I want to match all the words that contains the word "oana". I put "OANA" with uppercase letters in some words, at the beginning, middle, and at the end of words.
blah OANAmama blah aOANAtata aOANAt msmsmsOANAasfasfa mOANAmsmf OANAtata OANA3 oanTy
Anyway, I made a regex, but it is not very good, because it doesn't select all words that contains "oana"
\b\w+(oana)\w+\b
Can anyone give me another solution?
You need to use a case insensitive flag and replace +
with *
:
/\b\w*oana\w*\b/i
See the regex demo (a global modifier may or may not be used, depending on the regex engine). The case insensitive modifier may be passed as an inline option in some regex engines - (?i)\b\w*oana\w*\b
.
Here,
\b
- a word boundary \w*
- 0+ word charsoana
- the required char string inside a word\w*
- 0+ word chars\b
- a word boundary