-1

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

Hart
  • 7
  • 1
  • 2
    You can use `\bitch\w*` or `\bitch[a-z]*\b` – Wiktor Stribiżew Dec 17 '22 at 16:02
  • 1
    `^itch` actually finds both `itchy` and `itching` as long as they are at beginning of line (in most regex tools; you are not divulging which you are using, in violation of the [tag guidance](/tags/regex/info)). – tripleee Dec 17 '22 at 17:11

1 Answers1

2

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.

fjs
  • 330
  • 2
  • 9