Regular expressions | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Regular expressions

import re def solution(s, markers): markers = "".join(markers) return re.sub(r'\s(?=\n)', '', re.sub(rf'[{markers}][^\n]+', '', s)).rstrip() print(solution("\n#", ["#", "!"])) this code removes everything between the markers and a new line, but when the input is "\n#" it does not work. This is my first time using regular expressions so iam completely clueless on what to do, please help.

21st Jul 2020, 9:13 AM
Kirill - avatar
1 Answer
I forgot everything about regex cause I never use it but here is where I learned it
24th Jul 2020, 7:18 PM
Nydenii - avatar