I am going through text that looks like the below:
I'm goin|going to be here because I hafta|have to
I would like to strip the substring before the colon, and replace it with just the substring ater the color. Thus, the above string should look like
I'm going to be here because I have to
I know I can do this with a python loop, like below, but need the speed of a regular expression for this
s = "I'm goin|going to be here because I hafta|have to"
for word in s.split():
if '|' in word:
word = word.split('|')[1]
print(word)
I would like to use something like re.sub
to process this line, though.