I have a file where every block is separated by !s. i.e
!
vserver XXXX
virtual XX.xx.XX.XX tcp 389
owner LDAP
serverfarm XXX
idle 5
persistent rebalance
inservice
!
I want to get each section that is contains vserver info. I am trying to use regex in python, but I am having trouble dealing with the newline char
I tried something like this:
pattern = r"!\n vserver \S+\n "
You need to tell Python that you’re using multi-line regular expressions and that dot characters can match new-lines:
If you want to get the name of the vserver: