Home > Software design >  How to split line which has multple repeating texts
How to split line which has multple repeating texts

Time:07-20

I have a string

"abcabdfailedTestefgfailedTestsdfailedTest"

I need to split this line on basis of failedTest

tried using split() but no luck.

CodePudding user response:

If failedTest is the keyword that can be removed, you could replace failedTest with the linebreak character \n like this:

s = "abcabdfailedTestefgfailedTestsdfailedTest"
s_newline = s.replace('failedTest', '\n')

CodePudding user response:

if you want them on printed out on separate lines then you can use a for loop after you 'split('failed')'. After that you can print it with Testfailed or failedTest added on? Not quite sure if this is what you wanted as enough info was not specified but I hope this helped.

  • Related