Aug-04-2018, 04:43 PM
hey there, im a newbie who just started learning python, and i had a problem here:
i cant really find y its wrong. ik how to write it so that it does what its supposed to do but im just curious of the mistake ive made that i cannot find.
import re a = re.compile(r'(\d\d\d-){1,2}?\d\d\d\d') print(a.findall('111-222-1112, 111-333-2222, 155-2333'))so as u guys can probably see, i want the code to be able to identify both \d\d\d-\d\d\d\d and \d\d\d-\d\d\d-\d\d\d\d , but something went wrong, and the program ends up returning ['222-', '333-', '155-']
i cant really find y its wrong. ik how to write it so that it does what its supposed to do but im just curious of the mistake ive made that i cannot find.