Python noob here.
I have the following issue, there is a string which contains an episode of a series like this: "whatever S01E02 sowhat"
where series (01) can assume any value(01 until 99), and episode (02) also (01 until 99).. and I want to find this in the string.
I would like to use a clever way like
if string contains a sequence of str(S)+int+int+str(E)+int+int
then...
but all I did implement was a list containing all possible series (ij in the code) and episodes (kl in the code) and looped to create a list...
Does someone knows how to make this verification if a string contain a sequence of alphabetic+int+int+alphabetic+int+int
?
I found the following post Does Python have a string 'contains' substring method? to find substrings, but I couldn't adapt to have what I want.
I would like to search for a substring ("S"+int+int+"E"+int+int
)
where these ints may have any integer value in a clever way.
below is my implemented code:
series_episode = "Series whatever S01E04 formating no-one-cares"
list_SijEkl = []
i,j,k,l=0,1,0,1
while i < 2:
while j < 10:
k,l=0,1
while k<3:
while l<10:
list_SijEkl.append("S"+str(i)+str(j)+'E'+str(k)+str(l))
l+=1
l=0
k+=1
j+=1
i+=1
#print(list_SijEkl)
for episode in list_SijEkl:
if episode in series_episode:
cut = series_episode.split(episode)
before = cut[0]
after = cut[1]
print('cut before '+ before)
print('cut after'+ after)
print (before + episode)
print ('what i want in the end: '+before + episode)