Reputation: 11
I have this string
CPropVideoHC:\Users\DESKTOP\Desktop\Painel Bradesco\VT anuncie aqui jr vertical.mp4dX:C:\Users\DESKTOP\Desktop\Painel Bradesco\Vt play music.mp4dXGC:\Users\DESKTOP\Desktop\Painel Bradesco\VT chopp brahma vert jan22.mp4dXJC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Laura costa jul21 vertical.mp4dX<C:\Users\DESKTOP\Desktop\Painel Bradesco\Shed vert jan22.mp4dXCC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Big Italia vertical.mp4dXGC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Julia Carvalho Estetica.mp4dXCC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Jaqueline verticall.mp4dXAC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Adrenalina 7.5seg.mp4dXIC:\Users\DESKTOP\Desktop\Painel Bradesco\VT VIVA VINHO vertical dez21.mp4dXLC:\Users\DESKTOP\Desktop\Painel Bradesco\Vt Nutri La Vie Vertical 15 Seg.mp4dXDC:\Users\DESKTOP\Desktop\Painel Bradesco\VT good food vert nov21.mp4dX<C:\Users\DESKTOP\Desktop\Painel Bradesco\VT 141 vertical.mp4dXLC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Mestre Cervejeiro vert dez21.mp4dX>C:\Users\DESKTOP\Desktop\Painel Bradesco\VT Forla vertical.mp4dX>C:\Users\DESKTOP\Desktop\Painel Bradesco\AURORA - VERTICAL.mp4dXAC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Beto Ferreira TBE.mp4dXFC:\Users\DESKTOP\Desktop\Painel Bradesco\VT seu ze Spaten vertical.mp4dXCC:\Users\DESKTOP\Desktop\Painel Bradesco\DIAMOND VILLE VERTICAL.mp4dXEC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Liberty 31.01.22 vert.mp4dX@C:\Users\DESKTOP\Desktop\Painel Bradesco\ZOO_PAINEL_vertical.mp4dXDC:\Users\DESKTOP\Desktop\Painel Bradesco\Finissima_ Vertical_ v3.mp4dX@C:\Users\DESKTOP\Desktop\Painel Bradesco\Redel vertical novo.mp4dXAC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Valley vert jan22.mp4dXJC:\Users\DESKTOP\Desktop\Painel Bradesco\VT cafe lisboa ago21 com seta.mp4dXHC:\Users\DESKTOP\Desktop\Painel Bradesco\VT casa do fitness vertical.mp4dX>C:\Users\DESKTOP\Desktop\Painel Bradesco\Vt Educacoin vert.mp4dX>C:\Users\DESKTOP\Desktop\Painel Bradesco\VT HRA vert dez21.mp4dXEC:\Users\DESKTOP\Desktop\Painel Bradesco\VT virtual cafe vertical.mp4dX;C:\Users\DESKTOP\Desktop\Painel Bradesco\Vt Motel Luxor.mp4dXAC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Adrenalina 7.5seg.mp4dXEC:\Users\DESKTOP\Desktop\Painel Bradesco\VT seu ze petiscos nov21.mp4dXJC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Laura costa jul21 vertical.mp4dXRC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Lavanderia dimensao vertical dez21.mp4dXIC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Luna Terra calcados nov21.mp4dXGC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Petshop Peteca vertical.mp4dXIC:\Users\DESKTOP\Desktop\Painel
how to split this string with a start and an end word?
start with = C: end with = .mp4
["C:\Users\DESKTOP\Desktop\Painel Bradesco\VT anuncie aqui jr vertical.mp4",
"C:\Users\DESKTOP\Desktop\Painel Bradesco\Vt play music.mp4",
"C:\Users\DESKTOP\Desktop\Painel Bradesco\VT chopp brahma vert jan22.mp4",
"C:\Users\DESKTOP\Desktop\Painel Bradesco\VT Laura costa jul21 vertical.mp4"]
Upvotes: 0
Views: 415
Reputation: 2197
I think this regex solves your problem.
Note. Mark your initial string with r (raw string). As \U appears to be Unicode sequence and you will get an error
import re
string = r"CPropVideoHC:\Users\DESKTOP\Desktop\Painel Bradesco\VT anuncie aqui jr vertical.mp4dX:C:\Users\DESKTOP\Desktop\Painel Bradesco\Vt play music.mp4dXGC:\Users\DESKTOP\Desktop\Painel Bradesco\VT chopp brahma vert jan22.mp4dXJC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Laura costa jul21 vertical.mp4dX<C:\Users\DESKTOP\Desktop\Painel Bradesco\Shed vert jan22.mp4dXCC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Big Italia vertical.mp4dXGC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Julia Carvalho Estetica.mp4dXCC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Jaqueline verticall.mp4dXAC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Adrenalina 7.5seg.mp4dXIC:\Users\DESKTOP\Desktop\Painel Bradesco\VT VIVA VINHO vertical dez21.mp4dXLC:\Users\DESKTOP\Desktop\Painel Bradesco\Vt Nutri La Vie Vertical 15 Seg.mp4dXDC:\Users\DESKTOP\Desktop\Painel Bradesco\VT good food vert nov21.mp4dX<C:\Users\DESKTOP\Desktop\Painel Bradesco\VT 141 vertical.mp4dXLC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Mestre Cervejeiro vert dez21.mp4dX>C:\Users\DESKTOP\Desktop\Painel Bradesco\VT Forla vertical.mp4dX>C:\Users\DESKTOP\Desktop\Painel Bradesco\AURORA - VERTICAL.mp4dXAC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Beto Ferreira TBE.mp4dXFC:\Users\DESKTOP\Desktop\Painel Bradesco\VT seu ze Spaten vertical.mp4dXCC:\Users\DESKTOP\Desktop\Painel Bradesco\DIAMOND VILLE VERTICAL.mp4dXEC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Liberty 31.01.22 vert.mp4dX@C:\Users\DESKTOP\Desktop\Painel Bradesco\ZOO_PAINEL_vertical.mp4dXDC:\Users\DESKTOP\Desktop\Painel Bradesco\Finissima_ Vertical_ v3.mp4dX@C:\Users\DESKTOP\Desktop\Painel Bradesco\Redel vertical novo.mp4dXAC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Valley vert jan22.mp4dXJC:\Users\DESKTOP\Desktop\Painel Bradesco\VT cafe lisboa ago21 com seta.mp4dXHC:\Users\DESKTOP\Desktop\Painel Bradesco\VT casa do fitness vertical.mp4dX>C:\Users\DESKTOP\Desktop\Painel Bradesco\Vt Educacoin vert.mp4dX>C:\Users\DESKTOP\Desktop\Painel Bradesco\VT HRA vert dez21.mp4dXEC:\Users\DESKTOP\Desktop\Painel Bradesco\VT virtual cafe vertical.mp4dX;C:\Users\DESKTOP\Desktop\Painel Bradesco\Vt Motel Luxor.mp4dXAC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Adrenalina 7.5seg.mp4dXEC:\Users\DESKTOP\Desktop\Painel Bradesco\VT seu ze petiscos nov21.mp4dXJC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Laura costa jul21 vertical.mp4dXRC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Lavanderia dimensao vertical dez21.mp4dXIC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Luna Terra calcados nov21.mp4dXGC:\Users\DESKTOP\Desktop\Painel Bradesco\VT Petshop Peteca vertical.mp4dXIC:\Users\DESKTOP\Desktop\Painel "
for matched in re.findall("C:[^:]+.mp4", string):
print(matched)
This will have following output:
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT anuncie aqui jr vertical.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\Vt play music.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT chopp brahma vert jan22.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT Laura costa jul21 vertical.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\Shed vert jan22.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT Big Italia vertical.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT Jaqueline verticall.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT Adrenalina 7.5seg.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT VIVA VINHO vertical dez21.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\Vt Nutri La Vie Vertical 15 Seg.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT good food vert nov21.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT 141 vertical.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT Forla vertical.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT Beto Ferreira TBE.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT seu ze Spaten vertical.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT Liberty 31.01.22 vert.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\ZOO_PAINEL_vertical.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\Finissima_ Vertical_ v3.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\Redel vertical novo.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT Valley vert jan22.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT cafe lisboa ago21 com seta.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT casa do fitness vertical.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\Vt Educacoin vert.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT HRA vert dez21.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT virtual cafe vertical.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\Vt Motel Luxor.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT Adrenalina 7.5seg.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT seu ze petiscos nov21.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT Laura costa jul21 vertical.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT Lavanderia dimensao vertical dez21.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT Luna Terra calcados nov21.mp4
C:\Users\DESKTOP\Desktop\Painel Bradesco\VT Petshop Peteca vertical.mp4
P.S. Try writing code. At least try. It's worth nothing asking for help when you don't even try anything yourself
Upvotes: 3