# http://gist.github.com/271661
import lxml.html
import re
src = """
lksjdfls kdjff lsdfs sdjfls sdfsdwelcome
hello, my age is 86 years old and I was born in 1945. Do you know
that
PI is roughly 3.1443534534534534534 """
regex = re.compile('amazon_(\d+)')
doc = lxml.html.document_fromstring(s
In article <19de1d6e-5ba9-42b5-9221-ed7246e39...@u36g2000prn.googlegroups.com>,
Oltmans wrote:
>
>I've written this regex that's kind of working
>re.findall("\w+\s*\W+amazon_(\d+)",str)
>
>but I was just wondering that there might be a better RegEx to do that
>same thing. Can you kindly suggest a
On 21.12.2009 12:38, Oltmans wrote:
Hello,. everyone.
I've a string that looks something like
lksjdfls kdjff lsdfs sdjflssdfsdwelcome
> From above string I need the digits within the ID attribute. For
example, required output from above string is
- 35343433
- 345343
- 8898
I've w
On Dec 21, 5:38 am, Oltmans wrote:
> Hello,. everyone.
>
> I've a string that looks something like
>
> lksjdfls kdjff lsdfs sdjfls = "amazon_35343433">sdfsdwelcome
>
>
> From above string I need the digits within the ID attribute. For
> example, required output from above string is
how about re.findall(r'\w+.=\W\D+(\d+)?',str) ?
this will work for any string within id !
~Ukanth
On Dec 21, 6:06 pm, Oltmans wrote:
> On Dec 21, 5:05 pm, Umakanth wrote:
>
> > How about re.findall(r'\d+(?:\.\d+)?',str)
>
> > extracts only numbers from any string
>
> Thank you. However, I
> Oltmans wrote:
> >I've a string that looks something like
> >
> >lksjdfls kdjff lsdfs sdjfls >= "amazon_35343433">sdfsdwelcome
> >
> >
> >>From above string I need the digits within the ID attribute. For
> >example, required output from above string is
> >- 35343433
> >- 345343
> >-
Oltmans wrote:
Hello,. everyone.
I've a string that looks something like
lksjdfls kdjff lsdfs sdjfls sdfsdwelcome
From above string I need the digits within the ID attribute. For
example, required output from above string is
- 35343433
- 345343
- 8898
I've written this regex that
Ok. how about re.findall(r'\w+_(\d+)',str) ?
returns ['345343', '35343433', '8898', '8898'] !
On Dec 21, 6:06 pm, Oltmans wrote:
> On Dec 21, 5:05 pm, Umakanth wrote:
>
> > How about re.findall(r'\d+(?:\.\d+)?',str)
>
> > extracts only numbers from any string
>
> Thank you. However, I only
On Dec 21, 5:05 pm, Umakanth wrote:
> How about re.findall(r'\d+(?:\.\d+)?',str)
>
> extracts only numbers from any string
>
Thank you. However, I only need the digits within the ID attribute of
the DIV. Regex that you suggested fails on the following string
lksjdfls kdjff lsdfs sdjfl
Oltmans wrote:
> I've a string that looks something like
>
> lksjdfls kdjff lsdfs sdjfls = "amazon_35343433">sdfsdwelcome
>
>
> From above string I need the digits within the ID attribute. For
> example, required output from above string is
> - 35343433
> - 345343
> - 8898
>
> I'v
On Dec 21, 7:38 pm, Oltmans wrote:
> Hello,. everyone.
>
> I've a string that looks something like
>
> lksjdfls kdjff lsdfs sdjfls = "amazon_35343433">sdfsdwelcome
>
>
> From above string I need the digits within the ID attribute. For
> example, required output from above string is
How about re.findall(r'\d+(?:\.\d+)?',str)
extracts only numbers from any string
~uk
On Dec 21, 4:38 pm, Oltmans wrote:
> Hello,. everyone.
>
> I've a string that looks something like
>
> lksjdfls kdjff lsdfs sdjfls = "amazon_35343433">sdfsdwelcome
>
>
> From above string I n
Hello,. everyone.
I've a string that looks something like
lksjdfls kdjff lsdfs sdjfls sdfsdwelcome
>From above string I need the digits within the ID attribute. For
example, required output from above string is
- 35343433
- 345343
- 8898
I've written this regex that's kind of working
rh0dium wrote:
> Michael Spencer wrote:
>> >>> def parse(source):
>> ... source = source.splitlines()
>> ... original, rest = source[0], "\n".join(source[1:])
>> ... return original, rest_eval(get_tokens(rest))
>
> This is a very clean and elegant way to separate them - Very ni
"rh0dium" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Paul McGuire wrote:
>
> > ident = Combine( Word(alpha,alphanums+"_") + LPAR + RPAR )
>
> This will only work for a word with a parentheses ( ie. somefunction()
> )
>
> > If you *really* want everything on the first line to b
Michael Spencer wrote:
> >>> def parse(source):
> ... source = source.splitlines()
> ... original, rest = source[0], "\n".join(source[1:])
> ... return original, rest_eval(get_tokens(rest))
This is a very clean and elegant way to separate them - Very nice!! I
like this alot -
Paul McGuire wrote:
> ident = Combine( Word(alpha,alphanums+"_") + LPAR + RPAR )
This will only work for a word with a parentheses ( ie. somefunction()
)
> If you *really* want everything on the first line to be the ident, try this:
>
> ident = Word(alpha,alphanums+"_") + restOfLine
> or
> ide
rh0dium wrote:
> Hi all,
>
> I am using python to drive another tool using pexpect. The values
> which I get back I would like to automatically put into a list if there
> is more than one return value. They provide me a way to see that the
> data is in set by parenthesising it.
>
...
>
> CAN S
"rh0dium" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Paul McGuire wrote:
> > -- Paul
> > (Download pyparsing at http://pyparsing.sourceforge.net.)
>
> Done.
>
>
> Hey this is pretty cool! I have one small problem that I don't know
> how to resolve. I want the entire contents
Paul McGuire wrote:
> -- Paul
> (Download pyparsing at http://pyparsing.sourceforge.net.)
Done.
Hey this is pretty cool! I have one small problem that I don't know
how to resolve. I want the entire contents (whatever it is) of line 1
to be the ident. Now digging into the code showed a method
"rh0dium" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi all,
>
> I am using python to drive another tool using pexpect. The values
> which I get back I would like to automatically put into a list if there
> is more than one return value. They provide me a way to see that the
> d
Hi all,
I am using python to drive another tool using pexpect. The values
which I get back I would like to automatically put into a list if there
is more than one return value. They provide me a way to see that the
data is in set by parenthesising it.
This is all generated as I said using pexpec
22 matches
Mail list logo