I do not think that you can directly combine (logical and) character sets in one regular expression, regardless of whether it is negative or not. Otherwise, you could just combine [^\d] and \w .
Note. ^ must be at the beginning of the set and apply to the whole set. From the docs: "If the first character of the set is" ^ ", all characters that are not in the set will be matched." Your set [\w^\d] trying to match an alpha-numeric character, followed by a carriage, and then a digit. I can imagine that this also does not fit.
I would do this in two steps, effectively combining regular expressions. The first match is non-digital (internal regular expression), then the match is alphanumeric:
re.search('\w+', re.search('([^\d]+)', s).group(0)).group(0)
or variations of this theme.
Note that this would have to surround this with a try: except: block, since it will throw AttributeError: 'NoneType' object has no attribute 'group' if one of the two regular expressions fails. But you can, of course, split this line into several lines.
Evert source share