Tip of the Day: Find non-ASCII Characters with Regex

Search for non-ascii characters using regex: [^\x00-\x7F]+

An example using Python:

import re

valid_ascii = "abcdef"
non_ascii = "ðñò"

re.search("[^\x00-\x7F]+", valid_ascii+non_ascii)
<re.Match object; span=(52, 55), match='ðñò'>
Nicholas Nadeau, Ph.D., P.Eng.
Nicholas Nadeau, Ph.D., P.Eng.

Nicholas Nadeau empowers teams through fractional CTO services to build next-generation technologies. Subscribe to my newsletter to keep up with the latest trends and explore my services to jumpstart your innovation.