Re: string parsing / regexp question

2007-11-28 Thread Ryan Krauss
On Nov 28, 2007 1:23 PM, Paul McGuire <[EMAIL PROTECTED]> wrote: > On Nov 28, 11:32 am, "Ryan Krauss" <[EMAIL PROTECTED]> wrote: > > I need to parse the following string: > > > > $$\pmatrix{{\it x_2}\cr 0\cr 1\cr }=\pmatrix{\left({{{\it m_2}\,s^2 > > }\over{k}}+1\right)\,{\it x_1}-{{F}\over{k}}\cr

Re: string parsing / regexp question

2007-11-28 Thread Ryan Krauss
Interesting. Thanks Paul and Tim. This looks very promising. Ryan On Nov 28, 2007 1:23 PM, Paul McGuire <[EMAIL PROTECTED]> wrote: > On Nov 28, 11:32 am, "Ryan Krauss" <[EMAIL PROTECTED]> wrote: > > I need to parse the following string: > > > > $$\pmatrix{{\it x_2}\cr 0\cr 1\cr }=\pmatrix{\left

Re: string parsing / regexp question

2007-11-28 Thread Tim Chase
Paul McGuire wrote: > On Nov 28, 1:23 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: >> As Tim Grove points out, ... > > s/Grove/Chase/ > > Sorry, Tim! No problem...it's not like there aren't enough Tim's on the list as it is. :) -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: string parsing / regexp question

2007-11-28 Thread Paul McGuire
On Nov 28, 1:23 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: > As Tim Grove points out, ... s/Grove/Chase/ Sorry, Tim! -- Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: string parsing / regexp question

2007-11-28 Thread Paul McGuire
On Nov 28, 11:32 am, "Ryan Krauss" <[EMAIL PROTECTED]> wrote: > I need to parse the following string: > > $$\pmatrix{{\it x_2}\cr 0\cr 1\cr }=\pmatrix{\left({{{\it m_2}\,s^2 > }\over{k}}+1\right)\,{\it x_1}-{{F}\over{k}}\cr -{{{\it m_2}\,s^2\,F > }\over{k}}-F+\left({\it m_2}\,s^2\,\left({{{\it m_

Re: string parsing / regexp question

2007-11-28 Thread Tim Chase
> The trick is that there are extra curly braces inside the \pmatrix{ } > strings and I don't know how to write a regexp that would count the > number of open and close curly braces and make sure they match, so > that it can find the correct ending curly brace. This criterion is pretty much a deal

Re: String parsing

2007-05-09 Thread Paul Boddie
Dennis Lee Bieber wrote: > > I was trying to stay with a solution the should have been available > in the version of Python equivalent to the Jython being used by the > original poster. HTMLParser, according to the documents, was 2.2 level. I guess I should read the whole thread before posting. ;

Re: String parsing

2007-05-09 Thread Paul Boddie
On 9 May, 06:42, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > [HTMLParser-based solution] Here's another approach using libxml2dom [1] in HTML parsing mode: import libxml2dom # The text, courtesy of Dennis. sample = """ """ # Parse the string in HTML mode. d = libxml2dom.parseString(sa

Re: String parsing

2007-05-09 Thread HMS Surprise
BTW, here's what I used, the other ideas have been squirreled away in my neat tricks and methods folder. for el in data.splitlines(): if el.find('LastUpdated') <> -1: s = el.split("=")[-1].split('"')[1] print 's:', s Thanks

Re: String parsing

2007-05-09 Thread HMS Surprise
> This looks to be simple HTML (and I'm presuming that's a type on > that ?> ending). A quick glance at the Python library reference (you do > have a copy, don't you) reveals at least two HTML parsing modules... > No that is not a typo and bears investigation. Thanks for the find. I foun

Re: String parsing

2007-05-08 Thread HMS Surprise
Thanks all. Carsten, you are here early and late. Do you ever sleep? ;^) -- http://mail.python.org/mailman/listinfo/python-list

Re: String parsing

2007-05-08 Thread Carsten Haese
On 8 May 2007 19:06:14 -0700, HMS Surprise wrote > Thanks for posting. Could you reccommend an HTML parser that can be > used with python or jython? BeautifulSoup (http://www.crummy.com/software/BeautifulSoup/) makes HTML parsing easy as pie, and sufficiently old versions seem to work with Jython.

Re: String parsing

2007-05-08 Thread Gabriel Genellina
En Tue, 08 May 2007 23:06:14 -0300, HMS Surprise <[EMAIL PROTECTED]> escribió: > Thanks for posting. Could you reccommend an HTML parser that can be > used with python or jython? Try BeautifoulSoup, which handles malformed pages pretty well. -- Gabriel Genellina -- http://mail.python.org/ma

Re: String parsing

2007-05-08 Thread HMS Surprise
On May 8, 9:19 pm, HMS Surprise <[EMAIL PROTECTED]> wrote: > Yes it could, after I isolate that one string. Making sure I that I > isolate that complete line and only that line is part of the problem. > It comes in as one large string... -- http://mail.python.org/mailman/listinfo/python-list

Re: String parsing

2007-05-08 Thread HMS Surprise
Yes it could, after I isolate that one string. Making sure I that I isolate that complete line and only that line is part of the problem. thanks for posting. jh -- http://mail.python.org/mailman/listinfo/python-list

Re: String parsing

2007-05-08 Thread HMS Surprise
Thanks for posting. Could you reccommend an HTML parser that can be used with python or jython? john -- http://mail.python.org/mailman/listinfo/python-list

Re: String parsing

2007-05-08 Thread Tim Leslie
On 8 May 2007 18:09:52 -0700, HMS Surprise <[EMAIL PROTECTED]> wrote: > > The string below is a piece of a longer string of about 2 > characters returned from a web page. I need to isolate the number at > the end of the line containing 'LastUpdated'. I can find > 'LastUpdated' with .find but n

Re: String parsing

2007-05-08 Thread Gabriel Genellina
En Tue, 08 May 2007 22:09:52 -0300, HMS Surprise <[EMAIL PROTECTED]> escribió: > The string below is a piece of a longer string of about 2 > characters returned from a web page. I need to isolate the number at > the end of the line containing 'LastUpdated'. I can find > 'LastUpdated' with .