How????are!!!you
I’d like to split the string into ['How','are','you'].
I’ve tried the following regex:
\?*|\!*
which does not work. However, the following regex works:
\?+|\!+
Anyone explain this to me?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As for why
\?*|\!*doesn’t work, just look at whatre.findallfinds:The alternation always takes the first branch if possible.
re.splittries to only split by nonempty matches, so you end up splitting by?but not!(since\?*will match any empty string,\!*will never match in a non-overlapping fashion).