I currently have a config file which has words starting in as "ltm AZ2b, then followed by a few lines of config and then finally followed by vs-index as the end of the line.
Here's an example:
ltm virtual ync-Prod-Environment-VS { ..... ..... } ... vs-index 56
--right under this is another config set:
ltm virtual ync-Prod-Environment-VS-AZ2b { ..... ..... } ... vs-index 45
As you can see above(highlighted as well), there are multiple sets of config, and each set starts with ,-VS (multiple lines of config under this) and another set of similar config with the same name but with AZ2b, like: -VS-AZ2b (multiple lines of config under this as well)
I'm trying to extract only the config set which starts with -VS-AZ2b and ends with its vs-index.
I've written the following code but it is not working very well:
import re
fhandle=open('C:/Python Programs/Active.txt', 'r') str=fhandle.read()
y=re.findall('^.+AZ2b .+? vs-index [0-9].', str, re.DOTALL)
for line in y: line = line.replace('\n', "\n") print line
The output that i get is everything - including the config set with -VS. Not sure why. Can someone help?
Just to check, i took a file and added only the config sets with -VS and the program did not return anything. So i guess the code is only partially correct.
Thanks!