Jun-27-2019, 01:04 PM
I want to match a specific string and once match start writing the next line after after the matched string.
from output save in x variable I want to match "Current configuration" then write then start writing from next line.
Heres the sample output sting.
from output save in x variable I want to match "Current configuration" then write then start writing from next line.
Heres the sample output sting.
show run Building configuration... Current configuration : 1505 bytes ! Content1 Content1 ! Content2 Content2Once matched write but starting from next line. heres the target output.
! Content1 Content1 ! Content2 Content2Sample Configuration(but string the for line and not matching):
str = """show run Building configuration... Current configuration : 1505 bytes ! Content1 Content1 ! Content2 Content2""" with open('test.txt', 'w') as x: print str if "Current configuration" in str: x.writelines(itertools.islice(str, 4, None))Thanks