Re: Looking for a regular expression for this...

2006-07-30 Thread Anthra Norell
- Original Message - From: <[EMAIL PROTECTED]> To: Sent: Friday, July 28, 2006 10:30 PM Subject: Looking for a regular expression for this... > Hi, > My string is a multi line string that contains "filename > \n" and "host \n" entries among

Re: Looking for a regular expression for this...

2006-07-28 Thread John Machin
[EMAIL PROTECTED] wrote: > OK, I tried this one. I am actually trying to parse dhcpd.conf file. > > def get_filename(self): > p = "^[ \t]*filename[ \t]+(\S+).*?host[ \t]+%s\s*$" % self.host > pat = re.compile(p, re.MULTILINE | re.DOTALL) > mo = pat.search(self.confdata) > if mo: >

Re: Looking for a regular expression for this...

2006-07-28 Thread malahal
OK, I tried this one. I am actually trying to parse dhcpd.conf file. def get_filename(self): p = "^[ \t]*filename[ \t]+(\S+).*?host[ \t]+%s\s*$" % self.host pat = re.compile(p, re.MULTILINE | re.DOTALL) mo = pat.search(self.confdata) if mo: return mo.group(1) else:

Re: Looking for a regular expression for this...

2006-07-28 Thread faulkner
idk, most regexes look surprisingly like undergrowth. malahal, why don't you parse s into a dict? read each couple of lines into a key-value pair. John Machin wrote: > [EMAIL PROTECTED] wrote: > > Hi, > > My string is a multi line string that contains "filename > > \n" and "host \n" entr

Re: Looking for a regular expression for this...

2006-07-28 Thread John Machin
[EMAIL PROTECTED] wrote: > Hi, > My string is a multi line string that contains "filename > \n" and "host \n" entries among other things. > > For example: s = """ filename X > host hostname1 > blah... > host hostname2 >

Looking for a regular expression for this...

2006-07-28 Thread malahal
Hi, My string is a multi line string that contains "filename \n" and "host \n" entries among other things. For example: s = """ filename X host hostname1 blah... host hostname2 blah... f