trying to find both "itchy" and "itching"
I can find just "itch" but id like to be able to code to find whole words.
^itch - obviously only finds root word
trying to find both "itchy" and "itching"
I can find just "itch" but id like to be able to code to find whole words.
^itch - obviously only finds root word
The \w
in Wictor’s answer matches any alphanumeric character, that is, 0-9a-zA-Z. If you don’t mind having words like “itch8y” in your output result, you can use \w
. Otherwise use [a-zA-Z]
to only match pure alphabetic letters.
\b
zero-width matches word boundary. The caret ^
you used matches beginning of line instead.
If it’s possible the word you’re looking for has capitalized first letter, better search for \b[Ii]tch[a-zA-Z]*\b
.