Regex words in lower case

0

I have a Regex that removes characters that are not letters or space, for a Python application. Ex:

var = re.sub('[^a-zA-Z \\]', '', "abc Abc aBC cde123 def-ghi $?!123")

Returning:

abc Abc aBC cde defghi

I also need to return everything in lowercase:

abc abc abc cde defghi
    
asked by anonymous 05.11.2018 / 21:11

1 answer

2

Regex does not make any changes to the text, it just identifies the text. In this case you are identifying the text and replacing it by empty, keeping the box of the original text. As the text has already been found, just call lower() in the returned string.

var = re.sub('[^a-zA-Z \\]', '', "string").lower()
    
05.11.2018 / 21:57