python regular expression help
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'
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
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 =
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
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 =
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
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
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
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=
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,
Hi, everyone,
I am extracting some information from a given string using python RE. The
string is ,for example,
s = 'a = 4 b =3.4 5.4 c = 4.5'
What I want is :
a = 4
b = 3.4 5.4
c = 4.5
Right now I use :
pattern = re.compile(r'\w+\s*=\s*.*?\s+')
lists = pattern.findall(s)
It
11 matches
Mail list logo