On Oct 16, 2008, at 11:25 PM, Steve Holden wrote:
Pat wrote:
Faheem Mitha wrote:
Hi,
I need to match a string of the form
capital_letter underscore capital_letter number
against a string of the form
anything capital_letter underscore capital_letter number
some_stuff_not_starting with a nu
Pat wrote:
> Faheem Mitha wrote:
>> Hi,
>>
>> I need to match a string of the form
>>
>> capital_letter underscore capital_letter number
>>
>> against a string of the form
>>
>> anything capital_letter underscore capital_letter number
>> some_stuff_not_starting with a number
>>
>
>> DUKE1_plat
Faheem Mitha wrote:
Hi,
I need to match a string of the form
capital_letter underscore capital_letter number
against a string of the form
anything capital_letter underscore capital_letter number
some_stuff_not_starting with a number
DUKE1_plateD_A12.CEL.
Thanks in advance. Please cc
Faheem Mitha:
> I need to match a string of the form
> ...
Please, show the code you have written so far, with your input-output
examples included (as doctests, for example), and we can try to find
ways to help you remove the bugs you have.
Bye,
bearophile
--
http://mail.python.org/mailman/listin
On Oct 25, 9:25 am, Peter Otten <[EMAIL PROTECTED]> wrote:
>
> You want a "negative lookahead assertion" then:
>
Now I feel dumb...
I've seen the (?!...) dozen times in the doc but never figure out that
it is what I'm looking for.
So this one is the winner:
s = re.search(r'create\s+or\s+replace\s
looping wrote:
> On Oct 25, 8:49 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>>
>> needle = re.compile(r'create\s+or\s+replace\s+package(\s+body)?\s+',
>> re.IGNORECASE)
>
> What I want here is a RE that return ONLY the line without the "body"
> keyword.
> Your RE
On Oct 25, 8:49 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>
> needle = re.compile(r'create\s+or\s+replace\s+package(\s+body)?\s+',
> re.IGNORECASE)
What I want here is a RE that return ONLY the line without the "body"
keyword.
Your RE return both.
I know I could u
On Thu, 25 Oct 2007 06:34:03 +, looping wrote:
> Hi,
> It's not really a Python question but I'm sure someone could help me.
>
> When I use RE, I always have trouble with this kind of search:
>
> Ex.
>
> I've a text file:
> """
> create or replace package XXX
> ...
>
> create or replace pa
cases all of which you need to handle?
Frederic
- Original Message -
From: <[EMAIL PROTECTED]>
Newsgroups: comp.lang.python
To:
Sent: Monday, August 21, 2006 11:35 PM
Subject: Re: Regular Expression question
> Hi, thanks everyone for the information! Still going through it
Hi, thanks everyone for the information! Still going through it :)
The reason I did not match on tag2 in my original expression (and I
apologize because I should have mentioned this before) is that other
tags could also have an attribute with the value of "adj__" and the
attribute name may not be
[EMAIL PROTECTED] wrote:
> got zero results on this one :)
Really?
>>> s = '''
'''
>>> pat = re.compile('tag1.+?name="(.+?)".*?(?:<)(?=tag2).*?="adj__(.*?)__',
>>> re.DOTALL)
>>> m = re.findall(pat, s)
>>> m
[('john', 'tall'), ('joe', 'short')]
Regards,
Rob
--
http://mail.python.org/m
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi, I am having some difficulty trying to create a regular expression.
>
> Consider:
>
>
>
>
>
>
> Whenever a tag1 is followed by a tag 2, I want to retrieve the values
> of the tag1:name and tag2:value attributes. So my end resul
On 2006-08-21, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hi, I am having some difficulty trying to create a regular expression.
>
> Consider:
>
>
>
>
>
>
> Whenever a tag1 is followed by a tag 2, I want to retrieve the
> values of the tag1:name and tag2:value attributes. So my end
> result
[EMAIL PROTECTED] wrote:
> Hi, I am having some difficulty trying to create a regular expression.
Steve,
I find this tool is great for debugging regular expressions.
http://kodos.sourceforge.net/
Just put some sample text in one window, your trial RE in another, and
Kodos displays a wealth of
[EMAIL PROTECTED] wrote:
> Hi, I am having some difficulty trying to create a regular expression.
>
> Consider:
>
>
>
>
>
>
> Whenever a tag1 is followed by a tag 2, I want to retrieve the values
> of the tag1:name and tag2:value attributes. So my end result here
> should be
> john, tal
got zero results on this one :)
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> Thanks, i just tried it but I got the same result.
>
> I've been thinking about it for a few hours now and the problem with
> this approach is that the .*? before the (?=tag2) may have matched a
> tag1 and i don't know how to detect it.
Maybe like this:
'tag1.+?name="(.
I am not expert of REs yet, this my first possible solution:
import re
txt = """
"""
tfinder = r"""<# The opening < the tag to find
\s* # Possible space or newline
(tag[12]) # First subgroup, the identifier, tag1
or tag2
Thanks, i just tried it but I got the same result.
I've been thinking about it for a few hours now and the problem with
this approach is that the .*? before the (?=tag2) may have matched a
tag1 and i don't know how to detect it.
And even if I could, how would I make the search reset its start
pos
[EMAIL PROTECTED] wrote:
> Hi, I am having some difficulty trying to create a regular expression.
>
> Consider:
>
>
>
>
>
>
> Whenever a tag1 is followed by a tag 2, I want to retrieve the values
> of the tag1:name and tag2:value attributes. So my end result here
> should be
> john, tall
>
Paul McGuire wrote:
>> import re
>> r=re.compile('[^"]+)"[^>]*>',re.IGNORECASE)
>> for m in r.finditer(html):
>> print m.group('image')
>>
>
> Ouch - this fails to match any tag that has some other
> attribute, such as "height" or "width", before the "src" attribute.
> www.yahoo.com has sev
"Frank Potter" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> pyparsing is cool.
> but use only re is also OK
> # -*- coding: UTF-8 -*-
> import urllib2
> html=urllib2.urlopen(ur"http://www.yahoo.com/";).read()
>
> import re
> r=re.compile('[^"]+)"[^>]*>',re.IGNORECASE)
> for m in r.
pyparsing is cool.
but use only re is also OK
# -*- coding: UTF-8 -*-
import urllib2
html=urllib2.urlopen(ur"http://www.yahoo.com/";).read()
import re
r=re.compile('[^"]+)"[^>]*>',re.IGNORECASE)
for m in r.finditer(html):
print m.group('image')
I got these rusults:
http://us.i1.yimg.com/us.yi
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
> I am new to python regular expression, I would like to use it to get an
> attribute of an html element from an html file?
>
> for example, I was able to read the html file using this:
>req = urllib2.Request(url=acaURL)
> f
I'm sorry! I mean pattern is an argument of the function, in this case, how I process special charactors. patter = 'www.' # not this if re.compile(pattern).match(string) is not None: .. but not: if re.compile(r'www.').match(string) is not None
[EMAIL PROTECTED] wrote:
> I am new to python regular expression, I would like to use it to get an
> attribute of an html element from an html file?
if you want to parse HTML, use an HTML parser. if you want to parse
sloppy HTML, use a tolerant HTML parser:
http://www.crummy.com/software/
Michelle McCall wrote:
>I have a script that needs to scan every line of a file for numerous
> strings. There are groups of strings for each "area" of data we are looking
> for. Looping through each of these list of strings separately for each line
> has slowed execution to a crawl. Can I creat
On Mon, 7 Nov 2005 16:38:11 -0800, James Stroud <[EMAIL PROTECTED]> wrote:
>On Monday 07 November 2005 16:18, [EMAIL PROTECTED] wrote:
>> Ya, for some reason your non-greedy "?" doesn't seem to be taking.
>> This works:
>>
>> re.sub('(.*)(00.*?01) target_mark', r'\2', your_string)
>
>The non-greed
On Monday 07 November 2005 17:31, Kent Johnson wrote:
> James Stroud wrote:
> > On Monday 07 November 2005 16:18, [EMAIL PROTECTED] wrote:
> >>Ya, for some reason your non-greedy "?" doesn't seem to be taking.
> >>This works:
> >>
> >>re.sub('(.*)(00.*?01) target_mark', r'\2', your_string)
> >
> >
James Stroud wrote:
> On Monday 07 November 2005 16:18, [EMAIL PROTECTED] wrote:
>
>>Ya, for some reason your non-greedy "?" doesn't seem to be taking.
>>This works:
>>
>>re.sub('(.*)(00.*?01) target_mark', r'\2', your_string)
>
>
> The non-greedy is actually acting as expected. This is because
On Monday 07 November 2005 16:18, [EMAIL PROTECTED] wrote:
> Ya, for some reason your non-greedy "?" doesn't seem to be taking.
> This works:
>
> re.sub('(.*)(00.*?01) target_mark', r'\2', your_string)
The non-greedy is actually acting as expected. This is because non-greedy
operators are "forwar
Ya, for some reason your non-greedy "?" doesn't seem to be taking.
This works:
re.sub('(.*)(00.*?01) target_mark', r'\2', your_string)
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> Hi,
>
> I'm having trouble extracting substrings using regular expression. Here
> is my problem:
>
> Want to find the substring that is immediately before a given
> substring. For example: from
> "00 noise1 01 noise2 00 target 01 target_mark",
> want to get
> "00 target
Bruno Desthuilliers wrote:
>> match = STX + '(.*)' + ETX
>>
>> # Example 1
>> # This appears to work, but I'm not sure if the '+' is being used in
>> the regular expression, or if it's just joining STX, '(.*)', and ETX.
>>
>> if re.search(STX + '(.*)' + ETX,data):
>> print "Matches"
>>
>> # Exam
> You may want something like:
> if re.search('%s(.*)%s' % (STX, ETX), data):
>
Ah I didn't even think about that...
Chris
--
http://mail.python.org/mailman/listinfo/python-list
snacktime a écrit :
The primary question is how do I perform a match when the regular
expression contains string variables? For example, in the following
code I want to match a line that starts with STX, then has any number
of characters, then ends with STX.
Example 2 I'm pretty sure works as I ex
36 matches
Mail list logo