.*? 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
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
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
--- 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
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
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
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.
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
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
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:
>>
[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
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
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
-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
[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
[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
<[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
"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
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
[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
[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
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
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
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
[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.
Interesting... thank you.
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
Great I will test this out once I have the time... thanks for the quick
response
--
http://mail.python.org/mailman/listinfo/python-list
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
32 matches
Mail list logo