Re: [Tutor] Regular expressions question

2012-12-06 Thread Mark Lawrence
On 06/12/2012 11:31, Steven D'Aprano wrote: On 06/12/12 20:53, Albert-Jan Roskam wrote: Lately I started using named groups (after I didn't understand some of my own regexes I wrote several months earlier). Months? I can't understand my own regexes about six seconds after I look away from t

Re: [Tutor] Regular expressions question

2012-12-06 Thread Steven D'Aprano
On 06/12/12 20:53, Albert-Jan Roskam wrote: Lately I started using named groups (after I didn't understand some of my own regexes I wrote several months earlier). Months? I can't understand my own regexes about six seconds after I look away from the screen. The downside is that the regexes

Re: [Tutor] Regular expressions question

2012-12-06 Thread Albert-Jan Roskam
___ >From: eryksun >To: Ed Owens >Cc: "tutor@python.org" >Sent: Thursday, December 6, 2012 3:08 AM >Subject: Re: [Tutor] Regular expressions question > >On Wed, Dec 5, 2012 at 7:13 PM, Ed Owens wrote: >>>>> str(string

Re: [Tutor] Regular expressions question

2012-12-05 Thread eryksun
On Wed, Dec 5, 2012 at 7:13 PM, Ed Owens wrote: str(string) > '[\nUpdated: > Dec 5, 2012, 5:08pm EST\n]' m = re.search('":\b(\w+\s+\d+,\s+\d+,\s+\d+:\d+.m\s+\w+)<', str(string)) print m > None You need a raw string for the boundary marker \b (i.e the boundary between \w and \W), el

Re: [Tutor] Regular expressions question

2012-12-05 Thread Brett Ritter
On Wed, Dec 5, 2012 at 5:04 PM, Ed Owens wrote: > >>> m = re.search(':\b(\w+\s+\d+,\s+\d+,\s+\d+:\d+.m\s+\w+)<', str(string)) > >>> print m > None > >>> > Okay, without the double-quote (it wasn't the colon that I was worried about, it was the double-quote), I believe the issue now is that you h

Re: [Tutor] Regular expressions question

2012-12-05 Thread Alan Gauld
On 06/12/12 00:24, Brett Ritter wrote: '[\nUpdated: Dec 5, 2012, 5:08pm EST\n]' >>> m = re.search('":\b(\w+\s+\d+,\s+\__d+,\s+\d+:\d+.m\s+\w+)<', It starts with ": which doesn't appear in your string. At the end of Updated: -- Alan G Author of the Learn to Program web site http://w

Re: [Tutor] Regular expressions question

2012-12-05 Thread Alan Gauld
On 06/12/12 00:13, Ed Owens wrote: >>> str(string) '[\nUpdated: Dec 5, 2012, 5:08pm EST\n]' >>> m = re.search('":\b(\w+\s+\d+,\s+\d+,\s+\d+:\d+.m\s+\w+)<', str(string)) >>> print m None >>> I'm sort of embarrassed to ask this, but I've been staring at this regular expression for hours and ca

Re: [Tutor] Regular expressions question

2012-12-05 Thread Ed Owens
On 12/5/12 7:24 PM, Brett Ritter wrote: On Wed, Dec 5, 2012 at 4:13 PM, Ed Owens > wrote: >>> str(string) '[\nUpdated: Dec 5, 2012, 5:08pm EST\n]' >>> m = re.search('":\b(\w+\s+\d+,\s+\d+,\s+\d+:\d+.m\s+\w+)<', str(string)) >>> print m None I

Re: [Tutor] Regular expressions question

2012-12-05 Thread Brett Ritter
On Wed, Dec 5, 2012 at 4:13 PM, Ed Owens wrote: > >>> str(string) > '[\nUpdated: Dec 5, 2012, 5:08pm EST\n]' > >>> m = re.search('":\b(\w+\s+\d+,\s+\**d+,\s+\d+:\d+.m\s+\w+)<', > str(string)) > >>> print m > None > It starts with ": which doesn't appear in your string. -- Brett Ritter / SwiftO

[Tutor] Regular expressions question

2012-12-05 Thread Ed Owens
>>> str(string) '[\nUpdated: Dec 5, 2012, 5:08pm EST\n]' >>> m = re.search('":\b(\w+\s+\d+,\s+\d+,\s+\d+:\d+.m\s+\w+)<', str(string)) >>> print m None >>> I'm sort of embarrassed to ask this, but I've been staring at this regular expression for hours and can't see why it doesn't work. I'm tr

Re: [Tutor] regular expressions question]

2006-08-12 Thread nimrodx
Hi Alan and other Gurus, if you look carefully at the string below, you see that in amongst the "\x" stuff you have the text I want: z tfile://home/alpha which I know to be an address on my system, plus a bit of preceeding txt. Alan Gauld wrote: >> The file's encoding is binary or something >> >>

Re: [Tutor] regular expressions question

2006-08-12 Thread Alan Gauld
> The file's encoding is binary or something > > Here is the first section of the file: > '\x00\x00\x00\x02\xb8,\x08\x9f\x00\x00z\xa8\x00\x00\x01\xf4\x00\x00\x01\xf4\x00\x00\x00t\x00f\x00i\x00l\x00e\x00:\x00/\x00h\x00o\x00m\x00e\x00/\x00a\x00l' > > Does that tell you anything? Recall that on a 32

[Tutor] regular expressions question

2006-08-12 Thread nimrodx
Hi All, I am trying to fish through the history file for the Konquerer web browser, and pull out the web sites visited. The file's encoding is binary or something Here is the first section of the file: '\x00\x00\x00\x02\xb8,\x08\x9f\x00\x00z\xa8\x00\x00\x01\xf4\x00\x00\x01\xf4\x00\x00\x00t\x00f