Re: python -regular expression - list element

2008-06-25 Thread Matimus
On Jun 25, 2:55 am, antar2 <[EMAIL PROTECTED]> wrote: > Hello, > > I am a beginner in Python and am not able to use a list element for > regular expression, substitutions. > > list1 = [ 'a', 'o' ] > list2 = ['star',  'day', 'work', 'hello'] > > Suppose that I want to substitute the vowels from list

Re: python -regular expression - list element

2008-06-25 Thread Chris
On Jun 25, 12:32 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > antar2 <[EMAIL PROTECTED]> writes: > > for x in list1: > >    re.compile(x) > >    for y in list2: > >            re.compile(y) > >            if x in y: > >                    z = re.sub(x, 'u', y) > > but this does not work > > You need

Re: python -regular expression - list element

2008-06-25 Thread A.T.Hofkamp
On 2008-06-25, antar2 <[EMAIL PROTECTED]> wrote: > I am a beginner in Python and am not able to use a list element for > regular expression, substitutions. > > list1 = [ 'a', 'o' ] > list2 = ['star', 'day', 'work', 'hello'] > > Suppose that I want to substitute the vowels from list2 that are in >

Re: python -regular expression - list element

2008-06-25 Thread Ben Finney
antar2 <[EMAIL PROTECTED]> writes: > for x in list1: >re.compile(x) > for y in list2: >re.compile(y) > if x in y: > z = re.sub(x, 'u', y) > but this does not work You need to frotz the hymangirator with spangule. That, or show us the actu

Re: python -regular expression - list element

2008-06-25 Thread cokofreedom
On Jun 25, 11:55 am, antar2 <[EMAIL PROTECTED]> wrote: > Hello, > > I am a beginner in Python and am not able to use a list element for > regular expression, substitutions. > > list1 = [ 'a', 'o' ] > list2 = ['star', 'day', 'work', 'hello'] > > Suppose that I want to substitute the vowels from lis

Re: python regular expression help

2007-04-12 Thread Qilong Ren
Hi, Yeah, a little bit tricky. Actually it is part of some Fortran input file. Thanks for suggestion! It helps a lot! Thanks,Qilong - Original Message From: Gabriel Genellina <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Sent: Wednesday, April 11, 2007 9:50:00 PM Subject: Re:

Re: python regular expression help

2007-04-12 Thread 7stud
On Apr 11, 11:15 pm, [EMAIL PROTECTED] wrote: > On Apr 11, 9:50 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > lhs = re.compile(r'\s*(\b\w+\s*=)') > for s in [ "a = 4 b =3.4 5.4 c = 4.5", > "a = 4.5 b = 'h' 'd' c = 4.5 3.5"]: > tokens = lhs.split(s) > results = [tokens[_] + tokens[_+1] for

Re: python regular expression help

2007-04-11 Thread Paul McGuire
On Apr 11, 11:50 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Wed, 11 Apr 2007 23:14:01 -0300, Qilong Ren <[EMAIL PROTECTED]> > escribió: > > > Thanks for reply. That actually is not what I want. Strings I am dealing > > with may look like this: > > s = 'a = 4.5 b = 'h' 'd' c =

Re: python regular expression help

2007-04-11 Thread attn . steven . kuo
On Apr 11, 9:50 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Wed, 11 Apr 2007 23:14:01 -0300, Qilong Ren <[EMAIL PROTECTED]> > escribió: > > > Thanks for reply. That actually is not what I want. Strings I am dealing > > with may look like this: > > s = 'a = 4.5 b = 'h' 'd' c = 4.5

Re: python regular expression help

2007-04-11 Thread 7stud
On Apr 11, 10:50 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Wed, 11 Apr 2007 23:14:01 -0300, Qilong Ren <[EMAIL PROTECTED]> > escribió: > > > Thanks for reply. That actually is not what I want. Strings I am dealing > > with may look like this: > > s = 'a = 4.5 b = 'h' 'd' c =

Re: python regular expression help

2007-04-11 Thread Qilong Ren
mes = re.compile(r'(\w+)\s*=').findall(s) the corresponding values values = re.split(r'\w+\s*=',s)[1:] It dose not look good but it works. What do you think? Thanks,Qilong - Original Message From: 7stud <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Sent: Wedn

Re: python regular expression help

2007-04-11 Thread Gabriel Genellina
En Wed, 11 Apr 2007 23:14:01 -0300, Qilong Ren <[EMAIL PROTECTED]> escribió: > Thanks for reply. That actually is not what I want. Strings I am dealing > with may look like this: > s = 'a = 4.5 b = 'h' 'd' c = 4.5 3.5' > What I want is > a = 4.5 > b = 'h' 'd' > c = 4.5 3.5

Re: python regular expression help

2007-04-11 Thread 7stud
On Apr 11, 7:41 pm, liupeng <[EMAIL PROTECTED]> wrote: > pattern = re.compile(r'\w+\s*=\s*[0-9]*.[0-9]*\s*') > lists = pattern.findall(s) > print lists > ['a=4 ', 'b=3.4 ', 'c=4.5'] > > On Wed, Apr 11, 2007 at 06:10:07PM -0700, Qilong Ren wrote: > > Hi, everyone, > > > I am extracting some informat

Re: python regular expression help

2007-04-11 Thread Qilong Ren
From: liupeng <[EMAIL PROTECTED]> To: python-list@python.org Sent: Wednesday, April 11, 2007 6:41:30 PM Subject: Re: python regular expression help pattern = re.compile(r'\w+\s*=\s*[0-9]*.[0-9]*\s*') lists = pattern.findall(s) print lists ['a=4 ', 'b=3.4 ', 'c=

Re: python regular expression help

2007-04-11 Thread liupeng
pattern = re.compile(r'\w+\s*=\s*[0-9]*.[0-9]*\s*') lists = pattern.findall(s) print lists ['a=4 ', 'b=3.4 ', 'c=4.5'] On Wed, Apr 11, 2007 at 06:10:07PM -0700, Qilong Ren wrote: > Hi, everyone, > > I am extracting some information from a given string using python RE. The > string is ,for example,

Re: Python regular expression

2006-12-05 Thread Roberto Bonvallet
Wehrdamned wrote: > As I understand it, python uses a pcre engine to work with regular > expression. [...] > My question is, then, why expressions like : re.compile('asd|(?-i:QWE)', re.I) [...] > don't work? They are ok in perl... >From http://docs.python.org/lib/module-re.html: This mo

Re: Python regular expression question!

2006-09-20 Thread unexpected
Sweet! Thanks so much! -- http://mail.python.org/mailman/listinfo/python-list

Re: Python regular expression question!

2006-09-20 Thread Ant
unexpected wrote: > > \b matches the beginning/end of a word (characters a-zA-Z_0-9). > > So that regex will match e.g. MULTX-FOO but not MULTX-. > > > > So is there a way to get \b to include - ? No, but you can get the behaviour you want using negative lookaheads. The following regex is effecti

Re: Python regular expression question!

2006-09-20 Thread unexpected
> \b matches the beginning/end of a word (characters a-zA-Z_0-9). > So that regex will match e.g. MULTX-FOO but not MULTX-. > So is there a way to get \b to include - ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python regular expression question!

2006-09-20 Thread Hallvard B Furuseth
"unexpected" <[EMAIL PROTECTED]> writes: > I'm trying to do a whole word pattern match for the term 'MULTX-' > > Currently, my regular expression syntax is: > > re.search(('^')+(keyword+'\\b') \b matches the beginning/end of a word (characters a-zA-Z_0-9). So that regex will match e.g. MULTX-FOO