Re: Regex help needed!

2010-01-07 Thread Aahz
In article 19de1d6e-5ba9-42b5-9221-ed7246e39...@u36g2000prn.googlegroups.com, Oltmans rolf.oltm...@gmail.com 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

Re: Regex help needed!

2010-01-07 Thread Rolando Espinoza La Fuente
# http://gist.github.com/271661 import lxml.html import re src = lksjdfls div id ='amazon_345343' kdjff lsdfs /div sdjfls div id = amazon_35343433sdfsd/divdiv id='amazon_8898'welcome/div hello, my age is 86 years old and I was born in 1945. Do you know that PI is roughly 3.1443534534534534534

Re: Regex help needed!

2009-12-24 Thread F.R.
On 21.12.2009 12:38, Oltmans wrote: Hello,. everyone. I've a string that looks something like lksjdflsdiv id ='amazon_345343' kdjff lsdfs/div sdjflsdiv id = amazon_35343433sdfsd/divdiv id='amazon_8898'welcome/div From above string I need the digits within the ID attribute. For

Re: Regex help needed!

2009-12-22 Thread Umakanth
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 rolf.oltm...@gmail.com wrote: On Dec 21, 5:05 pm, Umakanth cum...@gmail.com wrote: How about re.findall(r'\d+(?:\.\d+)?',str) extracts only numbers from any

Re: Regex help needed!

2009-12-22 Thread Paul McGuire
On Dec 21, 5:38 am, Oltmans rolf.oltm...@gmail.com wrote: Hello,. everyone. I've a string that looks something like lksjdfls div id ='amazon_345343' kdjff lsdfs /div sdjfls div id =   amazon_35343433sdfsd/divdiv id='amazon_8898'welcome/div From above string I need the digits

Regex help needed!

2009-12-21 Thread Oltmans
Hello,. everyone. I've a string that looks something like lksjdfls div id ='amazon_345343' kdjff lsdfs /div sdjfls div id = amazon_35343433sdfsd/divdiv id='amazon_8898'welcome/div From above string I need the digits within the ID attribute. For example, required output from above

Re: Regex help needed!

2009-12-21 Thread Umakanth
How about re.findall(r'\d+(?:\.\d+)?',str) extracts only numbers from any string ~uk On Dec 21, 4:38 pm, Oltmans rolf.oltm...@gmail.com wrote: Hello,. everyone. I've a string that looks something like lksjdfls div id ='amazon_345343' kdjff lsdfs /div sdjfls div id =  

Re: Regex help needed!

2009-12-21 Thread mik3
On Dec 21, 7:38 pm, Oltmans rolf.oltm...@gmail.com wrote: Hello,. everyone. I've a string that looks something like lksjdfls div id ='amazon_345343' kdjff lsdfs /div sdjfls div id =   amazon_35343433sdfsd/divdiv id='amazon_8898'welcome/div From above string I need the digits

Re: Regex help needed!

2009-12-21 Thread Peter Otten
Oltmans wrote: I've a string that looks something like lksjdfls div id ='amazon_345343' kdjff lsdfs /div sdjfls div id = amazon_35343433sdfsd/divdiv id='amazon_8898'welcome/div From above string I need the digits within the ID attribute. For example, required output from

Re: Regex help needed!

2009-12-21 Thread Oltmans
On Dec 21, 5:05 pm, Umakanth cum...@gmail.com 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 div id

Re: Regex help needed!

2009-12-21 Thread Umakanth
Ok. how about re.findall(r'\w+_(\d+)',str) ? returns ['345343', '35343433', '8898', '8898'] ! On Dec 21, 6:06 pm, Oltmans rolf.oltm...@gmail.com wrote: On Dec 21, 5:05 pm, Umakanth cum...@gmail.com wrote: How about re.findall(r'\d+(?:\.\d+)?',str) extracts only numbers from any string

Re: Regex help needed!

2009-12-21 Thread MRAB
Oltmans wrote: Hello,. everyone. I've a string that looks something like lksjdfls div id ='amazon_345343' kdjff lsdfs /div sdjfls div id = amazon_35343433sdfsd/divdiv id='amazon_8898'welcome/div From above string I need the digits within the ID attribute. For example, required

Re: Regex help needed!

2009-12-21 Thread Johann Spies
Oltmans wrote: I've a string that looks something like lksjdfls div id ='amazon_345343' kdjff lsdfs /div sdjfls div id = amazon_35343433sdfsd/divdiv id='amazon_8898'welcome/div From above string I need the digits within the ID attribute. For example, required output from

Regex help needed

2006-01-10 Thread rh0dium
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

Re: Regex help needed

2006-01-10 Thread Paul McGuire
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 data is in

Re: Regex help needed

2006-01-10 Thread rh0dium
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

Re: Regex help needed

2006-01-10 Thread Paul McGuire
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 (whatever it

Re: Regex help needed

2006-01-10 Thread Michael Spencer
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 SOMEONE

Re: Regex help needed

2006-01-10 Thread rh0dium
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 ident =

Re: Regex help needed

2006-01-10 Thread rh0dium
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 - I will

Re: Regex help needed

2006-01-10 Thread Paul McGuire
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 be the ident, try

Re: Regex help needed

2006-01-10 Thread Michael Spencer
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 nice!! I like