K
K
karrl2022-04-21 14:07:03
Python
karrl, 2022-04-21 14:07:03

Regular expressions in python, how to remove none from output?

The program should split the signatures(in brackets) how to fix none or limit the output to 1 correct result

while True:
import re
income = input('Enter a phrase:')
result1 = re.split(r"(Regards...)|( Best regards,)|(Sincerely yours)|(Looking forward to your reply)", income )
print(result1)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2022-04-21
@Vindicar

Remove the parentheses from the regular expression. What for are they there? And don't forget that the dot in regular expressions means "any character".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question