[Tutor] about Regular Expression

Bob Gailer bgailer@alum.rpi.edu
Sat Jun 21 13:34:01 2003


--=======57092849=======
Content-Type: text/plain; x-avg-checked=avg-ok-265E7091; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 8bit

At 08:53 AM 6/21/2003 -0700, Abdirizak abdi wrote:

>Hi,
>I was trying to sset up a regular expression that covers the following 
>numbers:
>
>6868 8901
>(02) 6868 8901
>
>this is the regular expression set up to cover:
>
>tee = re.compile(r'\b\(?\d?\d?\)?\s?\d+\d+\d+\d+\s\d+\d+\d+\d+\b')
>tuu = "(02) 8750 9529"
>tii = tee.findall(tuu)
>print tii
>
>MY PROBLEM is it is displaying this output:
>
>[ ' 02) 8750 9529']
>
>it misses the first bracket but don't know why:

THE PROBLEM is the \b which 'Matches a word boundary...."word' means 
"sequence of alphanumeric characters."' Remove the \b and it works.

Bob Gailer
bgailer@alum.rpi.edu
303 442 2625

--=======57092849=======
Content-Type: text/plain; charset=us-ascii; x-avg=cert; x-avg-checked=avg-ok-265E7091
Content-Disposition: inline


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.488 / Virus Database: 287 - Release Date: 6/5/2003

--=======57092849=======--