I wrote this regex.
(?i)(#?covid\s|#?covid\W|#?covid\d )
But it doesn't seem to match uppercase word (COVID). How can I improve it?
Note: One of the requirements is to match covid4me&u. So when there is a number after the word covid is a valid expression.
CodePudding user response:
Assuming you want to make sure you're not matching part of a word, I would use the \b
word-boundary instead of matching COVID followed by \W
or \s
:
(?i)#?covid\d*\b
This avoids problem matching covid at the end of lines that your solution was having.
To handle your updated question's needs I would use the following :
(?i)#?\bcovid(\b|\d )