I have a string that may contain non-alphanumeric characters and I need to ensure it only contains [^0-9a-zA-Z]. In CPython, I would do that using re.sub. Unfortunately the ure lib used in my ESP8266 build does not include this feature. What would be the best way to replicate this functionality?
Thanks in advance!
Best,
Kenny
Replace non-alphanumeric characters
Re: Replace non-alphanumeric characters
Code: Select all
new_string = "".join(c for c in old_string if c.isalnum())