Is re module of any use in Python ? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Is re module of any use in Python ?

If I want to match some character I can use the following code. if 'abc' in 'abcd': print('M') else: print('N') So why to use re module.Moreover re module seems to be complicated cause I am beginner 😕

27th May 2020, 5:52 PM
swaggy tarret
1 ответ
+ 3
Ahh, but what if you want to check if "a" followed by any other letter followed by "c" is in a much longer string? Then that becomes much more complicated to code without using regex - that's where it comes into its own. Yes, regex is complicated and it looks completely alien to the beginner but think about it, if there wasn't any use for it, why would someone have created it?
27th May 2020, 6:05 PM
Russ
Russ - avatar