Python String replace based on chars NOT in RegEx -
is possible create reqex finds characters not specific set?
rather blacklisting bunch of characters , replacing them, easier me allow set , replace characters not in set.
my set looks this: [.a-za-z0-9]
i this:
clean_filename = re.sub(r'([.a-za-z0-9])', "_", filename)
obviously code replace characters want keep, there way replace characters not in set?
yes, use ^
negation "modifier": r'[^.a-za-z0-9]'
Comments
Post a Comment