Baz Baz - 1 year ago 80
Python Question

Convert letters to lower case

I use the following with respect to letters from any language:

text = regex.sub("[^\p{alpha}\d]+"," ",text

Can I use
to convert letters to their lower case equivalent if such an equivalency exists? How would this regex look?

Answer Source

As oxtopus suggested, you can simply convert letters to their lowercase version with text.lower() (no need for a regular expression). This works with Unicode strings too (À -> à, etc.)