Note the w is now lowercase, because it represents all alphanumeric characters (note that that includes the underscore). The character class [^\w'] refers to anything that's not (^) either alphanumeric (\w) or an apostrophe.
Sign up to request clarification or add additional context in comments.
Comments
2
re.split(r"[^\w']+",text)
By starting a character class with ^, it inverts the definition, so [^\w'] is the inverse of [\w'], which would match an alphanumeric/underscore/apostrophe.