Baz Baz - 1 year ago 88
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
p{alpha}
to convert letters to their lower case equivalent if such an equivalency exists? How would this regex look?

EOL EOL
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.)