+ 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
Kirill - avatar
1 Respuesta
0
I forgot everything about regex cause I never use it but here is where I learned it https://www.youtube.com/playlist?list=PL4cUxeGkcC9g6m_6Sld9Q4jzqdqHd2HiD
24th Jul 2020, 7:18 PM
Nydenii
Nydenii - avatar