For example: How do I match the words kein, keine, keiner or keines with regex.
I know how I can check for optional characters:
\bkein(?:e)?(?:r|s)?\b
But this way I would also match keins and keinr which is not what I want.
CodePudding user response:
You may use this regex:
\bkein(?:e[rs]?)?\b
Breakdown:
\b: Word boundarykein: Matchkein(?:e[rs]?)?: Optional non-capture group to matcheorerores\b: Word boundary
CodePudding user response:
You can create a list of possible suffixes like:
\bkein(e|er|es)?\b
CodePudding user response:
If it's just to know if a word responds to that pattern you can use
kein(e|er|es)?$
