Re: regexp matching end of line or comma

2010-11-25 Thread Saul Spatz
On Nov 25, 8:40 am, Jean-Michel Pichavant wrote: > Hy guys, > > I'm struggling matching patterns ending with a comma ',' or an end of > line '$'. > > import re > > ex1 = 'sumthin,' > ex2 = 'sumthin' > m1 = re.match('(?P\S+),', ex1) > m2 = re.match('(?P\S+)$', ex2) > m3 = re.match('(?P\S+)[,$]', ex

Re: regexp matching end of line or comma

2010-11-25 Thread MRAB
On 25/11/2010 16:26, Jean-Michel Pichavant wrote: MRAB wrote: On 25/11/2010 14:40, Jean-Michel Pichavant wrote: Hy guys, I'm struggling matching patterns ending with a comma ',' or an end of line '$'. import re ex1 = 'sumthin,' ex2 = 'sumthin' m1 = re.match('(?P\S+),', ex1) m2 = re.match('(?

Re: regexp matching end of line or comma

2010-11-25 Thread Jean-Michel Pichavant
MRAB wrote: On 25/11/2010 14:40, Jean-Michel Pichavant wrote: Hy guys, I'm struggling matching patterns ending with a comma ',' or an end of line '$'. import re ex1 = 'sumthin,' ex2 = 'sumthin' m1 = re.match('(?P\S+),', ex1) m2 = re.match('(?P\S+)$', ex2) m3 = re.match('(?P\S+)[,$]', ex1) m4

Re: regexp matching end of line or comma

2010-11-25 Thread MRAB
On 25/11/2010 14:40, Jean-Michel Pichavant wrote: Hy guys, I'm struggling matching patterns ending with a comma ',' or an end of line '$'. import re ex1 = 'sumthin,' ex2 = 'sumthin' m1 = re.match('(?P\S+),', ex1) m2 = re.match('(?P\S+)$', ex2) m3 = re.match('(?P\S+)[,$]', ex1) m4 = re.match('(

Re: regexp matching end of line or comma

2010-11-25 Thread Sol Toure
Try this: '(?P\S+)(,|$)' On Thu, Nov 25, 2010 at 9:40 AM, Jean-Michel Pichavant < jeanmic...@sequans.com> wrote: > Hy guys, > > I'm struggling matching patterns ending with a comma ',' or an end of line > '$'. > > import re > > ex1 = 'sumthin,' > ex2 = 'sumthin' > m1 = re.match('(?P\S+),', ex1) >

regexp matching end of line or comma

2010-11-25 Thread Jean-Michel Pichavant
Hy guys, I'm struggling matching patterns ending with a comma ',' or an end of line '$'. import re ex1 = 'sumthin,' ex2 = 'sumthin' m1 = re.match('(?P\S+),', ex1) m2 = re.match('(?P\S+)$', ex2) m3 = re.match('(?P\S+)[,$]', ex1) m4 = re.match('(?P\S+)[,$]', ex2) print m1, m2 print m3 print m4