I have a text like this :
[14:38] kkkk[15:06] check [15:07] gffgfgfgfgfgfgfgfgfgfgfgf [15:08] dasdsadsadsdsds [15:09] tessssttt
I want to replace the time in the brackets with - and that each line starting with the time stamp will be separated and will be moved to a new line.
So the final output will be something like this :
kkkk
checkddssfsf
gffgfgfgfgfgfgfgfgfgfgfgf
dasdsadsadsdsds
tessssttt ssaf dsfdsf scfc
For replacing the time stamp i have this line ‘mod_string = re.sub(r’([^)]*)’ ,’’,orig_string)’
How should i proceed and which action should be committed first?
Now if i run it, the time will be removed but i will have a big string in one line : " kkkk checkccc "
I actually wanted to separate each string line by line but instead of something like this :
[14:38] kkkk
[15:06] check
[15:07] gffgfgfgfgfgfgfgfgfgfgfgf
[15:08] dasdsadsadsdsds
[15:09] tessssttt
it should look like this :
re.sub() replaces the pattern of the first argument with the string in the second - ofcourse if you tell it to replace it with an empty string, you will just delete it.
However according to your task, you want to replace it with [-], so why don’t you do that?
Then do you want to save the result as a string and add newlines, or as an array and split the string?