Re: regular expression help

2010-11-29 Thread goldtech
.*? fixed it. Every occurrence of the pattern is now affected, which is what I want. Thank you very much. -- http://mail.python.org/mailman/listinfo/python-list

Re: regular expression help

2010-11-29 Thread Tim Harig
Python 3.1.2 (r312:79147, Oct 9 2010, 00:16:06) [GCC 4.4.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> m="cccvlvlvlvnnnflfllffccclfnnnooo" >>> pattern = re.compile(r'ccc[^n]*nnn') >>> pattern.sub("||", m) '||flfllff||ooo' >>> # or, as

Re: regular expression help

2010-11-29 Thread Tim Harig
On 2010-11-30, goldtech wrote: > Hi, > > say: import re > m="cccvlvlvlvnnnflfllffccclfnnnooo" re.compile(r'ccc.*nnn') rtt=.sub("||",m) rtt > '||ooo' > > The regex is eating up too much. What I want is every non-overlapping > occurrence I think. > > so rtt would

Re: regular expression help

2010-11-29 Thread Yingjie Lan
--- On Tue, 11/30/10, goldtech wrote: > From: goldtech > Subject: regular expression help > To: python-list@python.org > Date: Tuesday, November 30, 2010, 9:17 AM > The regex is eating up too much. What I want is every > non-overlapping > occurrence I think. > > so rtt would be: > > '||flf

Re: Regular Expression Help

2009-04-12 Thread Graham Breed
Jean-Claude Neveu wrote: Hello, I was wondering if someone could tell me where I'm going wrong with my regular expression. I'm trying to write a regexp that identifies whether a string contains a correctly-formatted currency amount. I want to support dollars, UK pounds and Euros, but the exam

Re: Regular Expression Help

2009-04-11 Thread John Machin
On Apr 12, 2:19 pm, ru...@yahoo.com wrote: > On Apr 11, 9:42 pm, Jean-Claude Neveu > wrote: > > > My regexp that I'm matching against is: "^\$\£?\d{0,10}(\.\d{2})?$" > > > Here's how I think it should work (but clearly > > I'm wrong, because it does not actually work): > > > ^\$\£?      Require ze

Re: Regular Expression Help

2009-04-11 Thread rurpy
On Apr 11, 9:42 pm, Jean-Claude Neveu wrote: > My regexp that I'm matching against is: "^\$\£?\d{0,10}(\.\d{2})?$" > > Here's how I think it should work (but clearly > I'm wrong, because it does not actually work): > > ^\$\£? Require zero or one instance of $ or £ at the start of the string.

Re: regular expression, help

2009-01-27 Thread Vincent Davis
is BeautifulSoup really better? Since I don't know either I would prefer to learn only one for now. Thanks Vincent Davis On Tue, Jan 27, 2009 at 10:39 AM, MRAB wrote: > Vincent Davis wrote: > >> I think there are two parts to this question and I am sure lots I am >> missing. I am hoping an exa

Re: regular expression, help

2009-01-27 Thread MRAB
Vincent Davis wrote: I think there are two parts to this question and I am sure lots I am missing. I am hoping an example will help me I have a html doc that I am trying to use regular expressions to get a value out of. here is an example or the line Parcel ID: 39-034-15-009 I want to get the

Re: Regular expression help: unable to search ' # ' character in the file

2008-09-27 Thread dudeja . rajat
On Sat, Sep 27, 2008 at 1:58 PM, Fredrik Lundh <[EMAIL PROTECTED]>wrote: > [EMAIL PROTECTED] wrote: > > import re >> >> fd = open(file, 'r') >> line = fd.readline >> pat1 = re.compile("\#*") >>while(line): >>mat1 = pat1.search(line) >>if mat1: >>

Re: Regular expression help: unable to search ' # ' character in the file

2008-09-27 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: import re fd = open(file, 'r') line = fd.readline pat1 = re.compile("\#*") while(line): mat1 = pat1.search(line) if mat1: print line line = fd.readline() I strongly doubt that this is

Re: Regular expression help

2008-07-18 Thread Marc 'BlackJack' Rintsch
On Fri, 18 Jul 2008 10:04:29 -0400, Russell Blau wrote: > values = {} > for expression in line.split(" "): > if "=" in expression: > name, val = expression.split("=") > values[name] = val > […] > > And when you get to be a really hard-core Pythonista, you could write > the whol

Re: Regular expression help

2008-07-18 Thread nclbndk759
On Jul 18, 3:35 pm, Nick Dumas <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > I think you're over-complicating this. I'm assuming that you're going to > do a line graph of some sorta, and each new line of the file contains a > new set of data. > > The problem you m

Re: Regular expression help

2008-07-18 Thread Nick Dumas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I think you're over-complicating this. I'm assuming that you're going to do a line graph of some sorta, and each new line of the file contains a new set of data. The problem you mentioned with your regex returning a match object rather than a string i

Re: Regular expression help

2008-07-18 Thread Gerard flanagan
[EMAIL PROTECTED] wrote: Hello, I am new to Python, with a background in scientific computing. I'm trying to write a script that will take a file with lines like c afrac=.7 mmom=0 sev=-9.56646 erep=0 etot=-11.020107 emad=-3.597647 3pv=0 extract the values of afrac and etot and plot them. I'm r

Re: Regular expression help

2008-07-18 Thread Brad
[EMAIL PROTECTED] wrote: Hello, I am new to Python, with a background in scientific computing. I'm trying to write a script that will take a file with lines like c afrac=.7 mmom=0 sev=-9.56646 erep=0 etot=-11.020107 emad=-3.597647 3pv=0 extract the values of afrac and etot... Why not just sp

Re: Regular expression help

2008-07-18 Thread Russell Blau
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I am new to Python, with a background in scientific computing. I'm > trying to write a script that will take a file with lines like > > c afrac=.7 mmom=0 sev=-9.56646 erep=0 etot=-11.020107 emad=-3.597647 > 3pv=0 > > extract the values

Re: Regular Expression Help

2008-03-16 Thread Duncan Booth
"santhosh kumar" <[EMAIL PROTECTED]> wrote: > I have text like , > STRINGTABLE > BEGIN > ID_NEXT_PANE"Cambiar a la siguiente sección de laventana > \nSiguiente sección" > ID_PREV_PANE"Regresar a la sección anterior de > laventana\nSección anterior" > END > STRI

Re: Regular Expression Help

2008-02-26 Thread John Machin
On Feb 27, 6:28 am, [EMAIL PROTECTED] wrote: > Hi All, > > I have a python utility which helps to generate an excel file for > language translation. For any new language, we will generate the excel > file which will have the English text and column for interested > translation language. The transla

Re: Regular Expression help for parsing html tables

2006-10-29 Thread Paddy
[EMAIL PROTECTED] wrote: > Hello, > > I am having some difficulty creating a regular expression for the > following string situation in html. I want to find a table that has > specific text in it and then extract the html just for that immediate > table. > > the string would look something like th

Re: Regular Expression help for parsing html tables

2006-10-29 Thread Odalrick
[EMAIL PROTECTED] skrev: > Hello, > > I am having some difficulty creating a regular expression for the > following string situation in html. I want to find a table that has > specific text in it and then extract the html just for that immediate > table. > > the string would look something like t

Re: Regular Expression help for parsing html tables

2006-10-28 Thread Stefan Behnel
Hi Steve, [EMAIL PROTECTED] wrote: > I am having some difficulty creating a regular expression for the > following string situation in html. I want to find a table that has > specific text in it and then extract the html just for that immediate > table. Any reason why you can't use a real HTML pa

Re: Regular Expression help

2006-04-28 Thread Kent Johnson
Edward Elliott wrote: > [EMAIL PROTECTED] wrote: >> If you are parsing HTML, it may make more sense to use a package >> designed especially for that purpose, like Beautiful Soup. > > I don't know Beautiful Soup, but one advantage regexes have over some > parsers is handling malformed html. Beaut

Re: Regular Expression help

2006-04-27 Thread John Bokma
Edward Elliott <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: >> If you are parsing HTML, it may make more sense to use a package >> designed especially for that purpose, like Beautiful Soup. > > I don't know Beautiful Soup, but one advantage regexes have over some > parsers is handling ma

Re: Regular Expression help

2006-04-27 Thread Edward Elliott
[EMAIL PROTECTED] wrote: > If you are parsing HTML, it may make more sense to use a package > designed especially for that purpose, like Beautiful Soup. I don't know Beautiful Soup, but one advantage regexes have over some parsers is handling malformed html. Omitted closing tags can wreak havoc.

Re: Regular Expression help

2006-04-27 Thread RunLevelZero
Interesting... thank you. -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular Expression help

2006-04-27 Thread RunLevelZero
r']*>(.*?)' With a slight modification that did exactly what I wanted, and yes the findall was the only way to get all that I needed as I buffered all the read. Thanks a bunch. -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular Expression help

2006-04-27 Thread johnzenger
If what you need is "simple," regular expressions are almost never the answer. And how simple can it be if you are posting here? :) BeautifulSoup isn't all that hard. Observe: >>> from BeautifulSoup import BeautifulSoup >>> html = '10:00am - 11:00am: >> href="/tvpdb?d=tvp&id=167540528&[snip]>T

Re: Regular Expression help

2006-04-27 Thread RunLevelZero
I considered that but what I need is simple and I don't want to use another library for something so simple but thank you. Plus I don't understand them all that well :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular Expression help

2006-04-27 Thread johnzenger
If you are parsing HTML, it may make more sense to use a package designed especially for that purpose, like Beautiful Soup. -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular Expression help

2006-04-27 Thread RunLevelZero
Great I will test this out once I have the time... thanks for the quick response -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular Expression help

2006-04-27 Thread Edward Elliott
RunLevelZero wrote: > 10:00am - 11:00am: > Here is the re. > > findshows = > re.compile(r'(\d\d:\d\d\D\D\s-\s\d\d:\d\d\D\D:*.*)') 1. A regex remembers everything it matches -- no need to wrap the entire thing in parens. Just call group() on the returned MatchObject. 2. If all you want is the