I'm trying to get a regex to match the words it, its, and it's.
I'm using \b
to match words, but it seems like it is only matching characters. How can I get it to match anything, but whitespace?
Here is the regex so far: \b(it|it's|its)\b
. How can I get it to match exactly the words it, it's, and its?
This one will work:
\bit(?:'?s)?\b
Your pattern doesn't work with it's
because in the alternation the item it
(that is tested first) succeeds before it's
that is not tested at all. You can write \b(it's|it|its)\b
too.
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