Re: matching exactly a 4 digit number in python

2008-11-21 Thread harijay
Thanks John Machin and Mark Tolonen .. SO I guess the correct one is to use the word boundary meta character "\b" so r'\b\d{4}\b' is what I need since it reads a 4 digit number in between word boundaries Thanks a tonne, and this being my second post to comp.lang.python. I am always amazed at ho

Re: matching exactly a 4 digit number in python

2008-11-21 Thread skip
>> I am a few months new into python. I have used regexps before in perl >> and java but am a little confused with this problem. >> I want to parse a number of strings and extract only those that >> contain a 4 digit number anywhere inside a string >> However the regexp >

Re: matching exactly a 4 digit number in python

2008-11-21 Thread MRAB
George Sakkis wrote: On Nov 21, 4:46 pm, harijay <[EMAIL PROTECTED]> wrote: Hi I am a few months new into python. I have used regexps before in perl and java but am a little confused with this problem. I want to parse a number of strings and extract only those that contain a 4 digit number any

Re: matching exactly a 4 digit number in python

2008-11-21 Thread George Sakkis
On Nov 21, 4:46 pm, harijay <[EMAIL PROTECTED]> wrote: > Hi > I am a few months new into python. I have used regexps before in perl > and java but am a little confused with this problem. > > I want to parse a number of strings and extract only those that > contain a 4 digit number anywhere inside

Re: matching exactly a 4 digit number in python

2008-11-21 Thread John Machin
On Nov 22, 8:46 am, harijay <[EMAIL PROTECTED]> wrote: > Hi > I am a few months new into python. I have used regexps before in perl > and java but am a little confused with this problem. > > I want to parse a number of strings and extract only those that > contain a 4 digit number anywhere inside a

Re: matching exactly a 4 digit number in python

2008-11-21 Thread Mark Tolonen
"harijay" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I want to parse a number of strings and extract only those that contain a 4 digit number anywhere inside a string Try: p = re.compile(r'\b\d{4}\b') -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: matching exactly a 4 digit number in python

2008-11-21 Thread Mr . SpOOn
2008/11/21 harijay <[EMAIL PROTECTED]>: > Hi > I am a few months new into python. I have used regexps before in perl > and java but am a little confused with this problem. > > I want to parse a number of strings and extract only those that > contain a 4 digit number anywhere inside a string > > How

matching exactly a 4 digit number in python

2008-11-21 Thread harijay
Hi I am a few months new into python. I have used regexps before in perl and java but am a little confused with this problem. I want to parse a number of strings and extract only those that contain a 4 digit number anywhere inside a string However the regexp p = re.compile(r'\d{4}') Matches even