/User/hank/files/blabla/abc def.pdf -> abc def.pdf
^.+\\\\/([^\\\\/]+)$
![[applepie 123]] → applepie 123
(?<=...) 某東西開頭(?=...) 某東西結尾(?<=!\\\\[\\\\]).+?(?=\\\\]\\\\])'
apple.png, banana.png, orange.png → image 1.png, image 2.png, image 3.png
class SubCounter(object):
def __init__(self, start=1):
self.count = start - 1
def __call__(self, match):
self.count += 1
return f"image {self.count}{match.group(1)}"
re.sub(r"\\\\w*?(.png)", SubCounter(), "apple.png, banana.png, orange.png")