"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
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
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
[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
â» [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
¨ì©³¦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
> 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
â» [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
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
--
¨ì©³¦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.
",([^
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
- 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
[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:
>
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:
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
[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
>
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
17 matches
Mail list logo