Re: looking for a regular expression

2006-08-05 Thread Tim Roberts
"alex23" <[EMAIL PROTECTED]> wrote: >Tim Roberts wrote: >> What is your signature supposed to be? It looks like you are trying to >> inject ANSI terminal escape sequences. The vast majority of Usenet >> participants are now reading these articles through GUI newsreaders or >> web-based readers w

Re: looking for a regular expression

2006-08-03 Thread John Machin
Tim Roberts wrote: > What is your signature supposed to be? It looks like you are trying to > inject ANSI terminal escape sequences. The vast majority of Usenet > participants are now reading these articles through GUI newsreaders or > web-based readers which show this as 5 lines of unrecognizab

Re: looking for a regular expression

2006-08-03 Thread alex23
Tim Roberts wrote: > What is your signature supposed to be? It looks like you are trying to > inject ANSI terminal escape sequences. The vast majority of Usenet > participants are now reading these articles through GUI newsreaders or > web-based readers which show this as 5 lines of unrecognizabl

Re: looking for a regular expression

2006-08-03 Thread Tim Roberts
[EMAIL PROTECTED] (¨ì©³¦b²Ö¤°»ò°Ú¡H) wrote: > >¡° [EMAIL PROTECTED] (Peter Otten)¡n¤§»Ê¨¥¡G >> ¨ì©³¦b²Ö¤°»ò°Ú¡H wrote: >> > Thanks a lot! I have never thought of that. >> > But what if there's not only commas, but also periods and semicolons? I >> > want to find words between 2 near by punctuations

Re: looking for a regular expression

2006-08-03 Thread �쩳�b�֤����ڡH
※ [EMAIL PROTECTED] (Peter Otten)》之銘言: > 到底在累什麼啊? wrote: > > Thanks a lot! I have never thought of that. > > But what if there's not only commas, but also periods and semicolons? I > > want to find words between 2 near by punctuations. I think it would make > > it diffic

Re: looking for a regular expression

2006-08-02 Thread Peter Otten
¨ì©³¦b²Ö¤°»ò°Ú¡H wrote: >> How about >> my_string = "We the people of the United States, in order to form a >> more perfect union, establish justice, insure domestic >> tranquility,.." >> print (x for x in my_string.split(",") if "justice" in x).next() >> This isn't a regular expression, but i

Re: looking for a regular expression

2006-08-02 Thread Ant
> But what if there's not only commas, but also periods and semicolons? I > want to find words between 2 near by punctuations. I think it would make > it difficult to use split instead of regular expression. You could use re.split(r"\W", text) instead of the string split method to split on all non

Re: looking for a regular expression

2006-08-02 Thread �쩳�b�֤����ڡH
※ [EMAIL PROTECTED] (Thomas Nelson)》之銘言: > How about > my_string = "We the people of the United States, in order to form a > more perfect union, establish justice, insure domestic > tranquility,.." > print (x for x in my_string.split(",") if "justice" in x).next() > This isn't a reg

Re: looking for a regular expression

2006-08-01 Thread Thomas Nelson
How about my_string = "We the people of the United States, in order to form a more perfect union, establish justice, insure domestic tranquility,.." print (x for x in my_string.split(",") if "justice" in x).next() This isn't a regular expression, but it gives what you're looking for. THN --

Re: looking for a regular expression

2006-08-01 Thread Duncan Booth
¨ì©³¦b²Ö¤°»ò°Ú¡H wrote: > I want "justice" and the words between the 2 nearest commas, which is > > establish justice > > All I can come up with is > > r",(.*?justice.*?)," > > but the result is > >in order to form a more perfect union, establish justice > > Apreciate any help. ",([^

looking for a regular expression

2006-08-01 Thread �쩳�b�֤����ڡH
I want words between 2 nearby commas with a specific word in them. For example,in the text blow: "We the people of the United States, in order to form a more perfect union, establish justice, insure domestic tranquility,.." I want "justice" and the words between the 2 nearest commas, which i

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