I am a novice in regex and trying to understand it by solving small problems. So here I am with a problem which I couldn’t solve (warning: it may be extremely silly). Your inputs will help me understand the concept.
I want to write a regex which will match all items in list1 but none of those from list2
list1
pit
spot
spate
slap two
respite
list2
pt
Pot
peat
part
I was thinking like “give me all the items that starts with p|s|r and endswith it|ot|e|o
So i wrote ^[p|s|r].*[it|ot|e|o]$ which eventually resulted in undesired result.
Thanks in advance for your inputs.
In notepad you can’t do
oroperations (taken from Notepad++: A guide to using regular expressions and extended search mode and tested on my Notepad++ 5.9.3)This would work in other “standard” regexes 🙂
Try here. http://gskinner.com/RegExr/?2uudn
What were you doing was using the
[]instead of the grouping(). It was equivalent to:[itoe|](were the|was a “standard” character instead ofor) and in general everything in an[]is in or 🙂[ab]meansaorb.