Help with re.search function

Asked

Viewed 47 times

1

I have a for who plays at a dictionary to check what the user typed to see is the same, to call a function... the case at issue:

FOR

for x in abrir:
                if(re.search(abrir[x], user_response, re.IGNORECASE)):
                    print(abrir_coisas(user_response)) 

(if there’s a way to do it in an if I’d appreciate it too, but that’s not my question right now)

In the dictionary in question I have it:

abrir = {....26:'\\babrir notepad\\b', 27:'\\babra notepad\\b',...60:'\\b\\wabrir notepad\+\+', 61:'\\b\\wabra notepad\+\+'... 

Who in turn plays for it in function:

elif ((re.search('\\babrir notepad\\b', user_response, re.IGNORECASE)) or (re.search('\\babra notepad\\b', user_response, re.IGNORECASE))):
                if file == "notepad.exe":

and this

elif ((re.search('\\b\\wabrir notepad\+\+', user_response, re.IGNORECASE)) or (re.search('\\b\\wabra notepad\+\+', user_response, re.IGNORECASE))):
                if file == "notepad++.exe":

Except that it is ALWAYS opening NOTEPAD and not NOTEPAD++ no matter what I do, could anyone help me solve this? I imagine I’m forgetting to use some simple code, only I’m not getting it. Thank you.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.