+ 1
I try to run the following code in the compiler. But it doesn't give any result. Can anyone know how should I modify it?
coding error https://code.sololearn.com/c5x02sqQy2rW/?ref=app
15 Respostas
+ 7
Saeed Mozaffari Convert your regex pattern to a raw string as r'len(daught)er)'.
Also, you should close the file to avoid leaks using `fh.close()` on line 10.
+ 2
try your code on pc because there is no Emma.txt file in your android if it is exist in your device then you can't call here because you can only import such these directories only on pc not android.
+ 2
Saeed Mozaffari try this code hope it will help you. but try on computer not android and file should be exist in your computer Emma.txt
https://code.sololearn.com/cWFv8dcb3fHG/?ref=app
+ 1
Maninder Singh Thank you so much.
+ 1
Saeed Mozaffari i have bug in my code please change the f.read() into f.readlines() because we need to check line by line. I think you are doing re module it can be made more simple for more explanation watch this video.
https://youtu.be/K8L6KVGG-7o
+ 1
Maninder Singh Yes, I'm working on re module. Thank you.
+ 1
Emerson Prado Yes, in SoloLearn and i watched a tutorial video about regular expression in my own language.
0
Where is file "Emma.txt"?
0
Emerson Prado Where above code there is. In a folder named 'regular expression'. i save that file in a nodepad in my pc.
0
Saeed Mozaffari OK. Which are the file contents?
0
Maninder Singh On my pc it gives no output.
0
Emerson Prado 'Emma'
0
Saeed Mozaffari If your file only contains 'Emma' and you're trying to match for 'len(daught)er', it simply doesn't match, so you won't get any output. Populate your file with content that can match.
Did you study the RegEx classes?
0
Emerson Prado Excuse me, in regular expression re.search find and show an specific character from the file????
0
Saeed Mozaffari Not a specific character, but the string that matched the expression. For an example, 'len(daught)er' would match 'lendaughtet' and return 'daught'.