What does [- \ w] + mean in python regex?
[-\w]
says that either a word symbol ( A-Za-z0-9_
) or a dash ( -
) can go there .
Here's a pretty good site that will tell you what exactly your regex does: http://www.regex101.com/r/cJ2zT8
source to share
Square brackets create a "character class", which means "match any of the characters between those square brackets. In your case, that literal character -
or any word character is A-Z
, A-Z
0-9
or _
. +
In this case means" match one or more of the previous character class " This means that you are matching strings that contain one or more characters from the set A-Za-z0-9_-
.
source to share