0

Problem with re module

I am creating a compiler and I also knew how to use re but when i run code and input: public static var = "hello" "world" Code: import re STRING='(\'[^\']*\')|("(.[^"])*")' ID='[a-zA-Z_][a-z0-9A-Z_]*' INT='\d+' FLOAT='\\d+\\.\\d+' QUALIFIER='(static|global)?' SECURITY='(public|private|protected)?' OP='(\\+|-|*|/|%|^)' EXP='((('+STRING+'|'+ID+')((\\s)?('+STRING+'|'+ID+'))*|((('+INT+'|'+FLOAT+'|'+ID+')('+OP+'('+INT+'|'+ID+'|'+FLOAT+'))*)' ASSIGN='('+OP+')?=' STMT='\\s'+SECURITY+'\\s*'+QUALIFIER+'\\s*'+ASSIGN+'\\s*'+EXP+'\\s*' while True: print('\n') print(re.match(STMT,input('Enter : '))) Errror on re module occured (It is py error not a regex error) Please help me , What to do to solve this problem You can get the error why? Link to code => https://code.sololearn.com/cVmc3pI5qIOk/?ref=app

1st Sep 2019, 5:13 AM
Vishal gupta
Vishal gupta - avatar
1 ответ
0
Hello Vishal gupta , It seems the problem is into your regex patterns OP and EXP. I have solved it and now it is working without error. https://code.sololearn.com/ca3g1mfk4uPq/#py Now your turn to find out match string. Happy Coding ....!!!!
6th May 2020, 5:14 PM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar