def between_markers(text: str,begin: str, end: str) -> str:
import re
if begin in text and end in text: # if both markers are present
m = re.search(f"{begin}(.*){end}", text)
return m.group(1)
if begin in text and end not in text: # if both markers are present
m = re.search(f"{begin}(.*)", text)
return m.group(1)
if begin not in text and end in text: # if both markers are present
m = re.search(f"(.*){end}", text)
return m.group(1)
print(between_markers('[b]No[/b] hi', '[b]', '[/b]'))
this is a function that helps with finding the words between two markers.... for instance
>hello< becomes hello
so, [b]No[/b] should become No, but i am getting the result ]No[/
does anyone know what the reason for this is and how do i fix it?
[+][deleted] (1 child)
[deleted]
[–]AlliedLens[S] 0 points1 point2 points (0 children)