+ 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.
1 Antwort
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