Cameron Simpson wrote:
>| Because "\s{6}+"
>| has other meanings in different regex syntaxes and the designers didn't
>| want confusion?
>
> I think Python REs are supposed to be Perl compatible; ISTR an opening
> sentence to that effect...
>
I don't know the full history of how regex engines
On 05Oct2012 10:27, Evan Driscoll wrote:
| I can understand that you can create a grammar that excludes it. [...]
| Was it because such patterns often reveal a mistake?
For myself, I would consider that sufficient reason.
I've seen plenty of languages (C and shell, for example, though they
are n
On 2012-10-05 16:27, Evan Driscoll wrote:
On 10/05/2012 04:23 AM, Duncan Booth wrote:
A regular expression element may be followed by a quantifier.
Quantifiers are '*', '+', '?', '{n}', '{n,m}' (and lazy quantifiers
'*?', '+?', '{n,m}?'). There's nothing in the regex language which says
you can
On 10/05/2012 10:27 AM, Evan Driscoll wrote:
On 10/05/2012 04:23 AM, Duncan Booth wrote:
A regular expression element may be followed by a quantifier.
Quantifiers are '*', '+', '?', '{n}', '{n,m}' (and lazy quantifiers
'*?', '+?', '{n,m}?'). There's nothing in the regex language which says
you c
On 10/05/2012 04:23 AM, Duncan Booth wrote:
A regular expression element may be followed by a quantifier.
Quantifiers are '*', '+', '?', '{n}', '{n,m}' (and lazy quantifiers
'*?', '+?', '{n,m}?'). There's nothing in the regex language which says
you can follow an element with two quantifiers.
In
Cameron Simpson wrote:
> On 03Oct2012 21:17, Ian Kelly wrote:
>| On Wed, Oct 3, 2012 at 9:01 PM, contro opinion
>| wrote:
>| > why the "\s{6}+" is not a regular pattern?
>|
>| Use a group: "(?:\s{6})+"
>
> Yeah, it is probably a precedence issue in the grammar.
> "(\s{6})+" is also accepte
On 03Oct2012 21:17, Ian Kelly wrote:
| On Wed, Oct 3, 2012 at 9:01 PM, contro opinion wrote:
| > why the "\s{6}+" is not a regular pattern?
|
| Use a group: "(?:\s{6})+"
Yeah, it is probably a precedence issue in the grammar.
"(\s{6})+" is also accepted.
--
Cameron Simpson
Disclaimer: ERIM
On Thu, Oct 4, 2012 at 9:44 PM, Saroo Jain wrote:
> x3=re.match("\s{6}+",str)
>
> instead use
> x3=re.match("\s{6,}",str)
>
> This serves the purpose. And also give some food for thought for why the
> first one throws an error.
That matches six or more spaces, not multiples of six spaces.
--
ht
s@python.org] On Behalf Of
Mark Lawrence
Sent: Friday, October 05, 2012 3:29 AM
To: python-list@python.org
Subject: Re: + in regular expression
On 04/10/2012 04:01, contro opinion wrote:
>>>> str=" gg"
>>>> x1=re.match("\s+",str)
>>>
On 10/04/2012 04:59 PM, Mark Lawrence wrote:
why the "\s{6}+" is not a regular pattern?
Why are you too lazy to do any research before posting a question?
Errr... what?
I'm only somewhat familiar with the extra stuff that languages provide
in their regexs beyond true regular expressio
On 04/10/2012 04:01, contro opinion wrote:
str=" gg"
x1=re.match("\s+",str)
x1
<_sre.SRE_Match object at 0xb7354db0>
x2=re.match("\s{6}",str)
x2
<_sre.SRE_Match object at 0xb7337f38>
x3=re.match("\s{6}+",str)
Traceback (most recent call last):
File "", line 1, in
File "/usr/l
On Wed, Oct 3, 2012 at 9:01 PM, contro opinion wrote:
> why the "\s{6}+" is not a regular pattern?
Use a group: "(?:\s{6})+"
--
http://mail.python.org/mailman/listinfo/python-list
>>> str=" gg"
>>> x1=re.match("\s+",str)
>>> x1
<_sre.SRE_Match object at 0xb7354db0>
>>> x2=re.match("\s{6}",str)
>>> x2
<_sre.SRE_Match object at 0xb7337f38>
>>> x3=re.match("\s{6}+",str)
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.6/re.py", line 13
> Put simply, it doesn't occur often enough to be worth it. The cost
> outweighs the potential benefit.
I don't buy it. You could backtrack instead of failing for \b+ and
\b*, and it would be almost as fast as this optimization.
-- Devin
On Tue, Jan 3, 2012 at 1:57 PM, MRAB wrote:
> On 03/01/20
On 03/01/2012 09:45, Devin Jeanpierre wrote:
\\b\\b and \\b{2} aren't equivalent ?
This sounds suspiciously like a bug!
Why the wording is "should never" ? Repeating a zero-width assertion is not
forbidden, for instance :
import re
re.compile("\\b\\b\w+\\b\\b")
<_sre.SRE_Pattern obje
> \\b\\b and \\b{2} aren't equivalent ?
This sounds suspiciously like a bug!
> Why the wording is "should never" ? Repeating a zero-width assertion is not
> forbidden, for instance :
>
import re
re.compile("\\b\\b\w+\\b\\b")
> <_sre.SRE_Pattern object at 0xb7831140>
I believe this
The regular expression HOWTO
(http://docs.python.org/howto/regex.html#more-metacharacters) explains
the following
# --
zero-width assertions should never be repeated, because if they match
once at a given location, they can obviously be matched an infinite
number o
Lie Ryan wrote:
MRAB wrote:
You're almost there:
re.subn('\x61','b','')
or better yet:
re.subn(r'\x61','b','')
Wouldn't that becomes a literal \x61 instead of "a" as it is inside raw
string?
Yes. The re module will understand the \x sequence within a regular
expression.
MRAB wrote:
You're almost there:
re.subn('\x61','b','')
or better yet:
re.subn(r'\x61','b','')
Wouldn't that becomes a literal \x61 instead of "a" as it is inside raw
string?
--
http://mail.python.org/mailman/listinfo/python-list
jorma kala wrote:
Thanks very much for your reply.
What I mean is that I would like to use the ascii number in a regular
expression pattern.
For instance, if I want to substitute the occurrences of character 'a'
for the character 'b' in a string, instead of doing this:
re.subn('a','b','')
On Tue, Apr 28, 2009 at 4:58 AM, jorma kala wrote:
> Thanks very much for your reply.
> What I mean is that I would like to use the ascii number in a regular
> expression pattern.
> For instance, if I want to substitute the occurrences of character 'a' for
> the character 'b' in a string, instead
Thanks very much for your reply.
What I mean is that I would like to use the ascii number in a regular
expression pattern.
For instance, if I want to substitute the occurrences of character 'a' for
the character 'b' in a string, instead of doing this:
re.subn('a','b','')
I'd like to specify t
On Tue, Apr 28, 2009 at 4:05 AM, jorma kala wrote:
> Hi,
>
> How can I use the ascii number of a character in a regular expression
> (module re) instead of the character itself?
> Thanks very much
I refer you to the chr() and ord() built-in functions, which can
certainly be used to solve your pro
Hi,
How can I use the ascii number of a character in a regular expression
(module re) instead of the character itself?
Thanks very much
--
http://mail.python.org/mailman/listinfo/python-list
phasma wrote:
string = u"Привет"
(u'\u041f\u0440\u0438\u0432\u0435\u0442',)
string = u"Hi.Привет"
(u'Hi',)
the [\w\s] pattern you used matches letters, numbers, underscore, and
whitespace. "." doesn't fall into that category, so the "match" method
stops when it gets to that character.
ma
On Sep 5, 12:28 pm, phasma <[EMAIL PROTECTED]> wrote:
> string = u"ðÒÉ×ÅÔ"
All the characters are letters.
> (u'\u041f\u0440\u0438\u0432\u0435\u0442',)
>
> string = u"Hi.ðÒÉ×ÅÔ"
The third character isn't a letter and isn't whitespace.
> (u'Hi',)
>
> On Sep 4, 9:53špm, Fredrik Lundh <[EMAIL PRO
string = u"Привет"
(u'\u041f\u0440\u0438\u0432\u0435\u0442',)
string = u"Hi.Привет"
(u'Hi',)
On Sep 4, 9:53 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> phasma wrote:
> > Hi, I'm trying extract all alphabetic characters from string.
>
> > reg = re.compile('(?u)([\w\s]+)', re.UNICODE)
> > buf =
phasma wrote:
Hi, I'm trying extract all alphabetic characters from string.
reg = re.compile('(?u)([\w\s]+)', re.UNICODE)
buf = re.match(string)
But it's doesn't work. If string starts from Cyrillic character, all
works fine. But if string starts from Latin character, match returns
only Latin
On Sep 4, 3:42 pm, phasma <[EMAIL PROTECTED]> wrote:
> Hi, I'm trying extract all alphabetic characters from string.
>
> reg = re.compile('(?u)([\w\s]+)', re.UNICODE)
You don't need both (?u) and re.UNICODE: they mean the same thing.
This will actually match letters and whitespace.
> buf = re.ma
Hi, I'm trying extract all alphabetic characters from string.
reg = re.compile('(?u)([\w\s]+)', re.UNICODE)
buf = re.match(string)
But it's doesn't work. If string starts from Cyrillic character, all
works fine. But if string starts from Latin character, match returns
only Latin characters.
Plea
[when replying to a mailing list or newsgroup response please make sure
you include the list as a recipient, so the whole conversation is available]
André Martins wrote:
>
>> I know I can use a variable in regular expressions. I want to use a
>> regex to find something based on the beginning o
> I know I can use a variable in regular expressions. I want to use a
> regex to find something based on the beginning of the string. I am
> using yesterday's date to find all of my data from yesterday.
> Yesterday's date is 20070731, and assigned to the variable
> "yesterday_date". I want to loop
[EMAIL PROTECTED] wrote:
> I know I can use a variable in regular expressions. I want to use a
> regex to find something based on the beginning of the string. I am
> using yesterday's date to find all of my data from yesterday.
> Yesterday's date is 20070731, and assigned to the variable
> "yesterd
<[EMAIL PROTECTED]> wrote:
>I know I can use a variable in regular expressions. I want to use a
>regex to find something based on the beginning of the string.
You're coming from a Perl background, right? No-one else would
think of using a regexp for such a simple thing. There are two
things you n
...
> Yesterday's date is 20070731, and assigned to the variable
> "yesterday_date". I want to loop thru a directory and find all of the
> yesterday's data ONLY IF the feature class has the date at the
> BEGINNING of the filename.
...
> I can't figure out the
> syntax of inserting the "^" into the
On 2007-08-02, at 13:43, [EMAIL PROTECTED] wrote:
> I know I can use a variable in regular expressions. I want to use a
> regex to find something based on the beginning of the string. I am
> using yesterday's date to find all of my data from yesterday.
> Yesterday's date is 20070731, and assigned
I know I can use a variable in regular expressions. I want to use a
regex to find something based on the beginning of the string. I am
using yesterday's date to find all of my data from yesterday.
Yesterday's date is 20070731, and assigned to the variable
"yesterday_date". I want to loop thru a dir
On May 20, 2:27 am, "Hugo Ferreira" <[EMAIL PROTECTED]> wrote:
> Both Paddy (hackish) and McGuire (right tool for the job) ideas sound
> very interesting ;-) I'll definitely research on them further.
>
> Thanks for the support...
Hackis, hackISH!
Sir, I would have you know that the idea proffered
Both Paddy (hackish) and McGuire (right tool for the job) ideas sound
very interesting ;-) I'll definitely research on them further.
Thanks for the support...
On 19 May 2007 04:39:58 -0700, Paul McGuire <[EMAIL PROTECTED]> wrote:
> On May 19, 12:32 am, Paddy <[EMAIL PROTECTED]> wrote:
> > On May
On May 19, 12:32 am, Paddy <[EMAIL PROTECTED]> wrote:
> On May 16, 6:58 pm, "Hugo Ferreira" <[EMAIL PROTECTED]> wrote:
>
> > Hi!
>
> > Is it possible to "automagically" coerce the named groups to python types?
> > e.g.:
>
> > >>> type(re.match('(?P\d*)', '123').groupdict()['x'])
>
> >
>
> > But w
On May 16, 6:58 pm, "Hugo Ferreira" <[EMAIL PROTECTED]> wrote:
> Hi!
>
> Is it possible to "automagically" coerce the named groups to python types?
> e.g.:
>
> >>> type(re.match('(?P\d*)', '123').groupdict()['x'])
>
>
>
> But what I'm looking forward is for the type to be 'int'.
>
> Cheers!
>
> H
Hello Hugo,
> Is it possible to "automagically" coerce the named groups to python types?
> e.g.:
Not that I know of, however I use the following idiom:
match = my_regexp.find(some_string)
def t(name, convert=str):
return convert(match.group(name))
myint = t("field1", int)
HTH,
--
Miki <[EM
Hugo Ferreira wrote:
> Hi!
>
> Is it possible to "automagically" coerce the named groups to python types?
> e.g.:
>
type(re.match('(?P\d*)', '123').groupdict()['x'])
>
>
> But what I'm looking forward is for the type to be 'int'.
>
> Cheers!
>
> Hugo Ferreira
So apply the "int()" funct
Hi!
Is it possible to "automagically" coerce the named groups to python types? e.g.:
>>> type(re.match('(?P\d*)', '123').groupdict()['x'])
But what I'm looking forward is for the type to be 'int'.
Cheers!
Hugo Ferreira
--
http://mail.python.org/mailman/listinfo/python-list
Alex Martelli wrote:
> Christoph Conrad <[EMAIL PROTECTED]> wrote:
>
>
>>Hello Roger,
>>
>>
>>>since the length of the first sequence of the letter 'a' is 2. Yours
>>>accepts it, right?
>>
>>Yes, i misunderstood your requirements. So it must be modified
>>essentially to that what Tim Chase wrote:
How about:
pattern = re.compile('^([^a]|(a+[^ab]))*aaab')
Which basically says, "precede with arbitrarily many non-a's
or a sequences ending in non-b, then must have 3 as followed by a b."
cases = ["xyz123aaabbab", "xayz123aaabab", "xaaayz123aaabab",
"xyz123babaaabab", "xyz123aabbaaab
Christoph Conrad <[EMAIL PROTECTED]> wrote:
> Hallo Alex,
>
> >> r = re.compile("[^a]*a{3}b+(a+b*)*") matches = [s for s in
> >> listOfStringsToTest if r.match(s)]
>
> > Unfortunately, the OP's spec is even more complex than this, if we are
> > to take to the letter what you just quoted; e.g. aa
>> "xyz123aaabbaaabab"
>>
>> where you have "aaab" in there twice.
>
> Good suggestion.
I assumed that this would be a valid case. If not, the
expression would need tweaking.
>> ^([^b]|((?
> Looks good, although I've been unable to find a good
> explanation of the "negative lookbehind" constr
"Tim Chase" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> The below seems to pass all the tests you threw at it (taking the modified
> 2nd test into consideration)
>
> One other test that occurs to me would be
>
> "xyz123aaabbaaabab"
>
> where you have "aaab" in there twice.
Good
The below seems to pass all the tests you threw at it (taking the
modified 2nd test into consideration)
One other test that occurs to me would be
"xyz123aaabbaaabab"
where you have "aaab" in there twice.
-tkc
import re
tests = [
("xyz123aaabbab",True),
("xyz123aabbaaab", False),
("xay
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Roger L. Cauvin wrote:
>
>> > $ python test.py
>> > gotexpected
>> > ---
>> > accept accept
>> > reject reject
>> > accept accept
>> > reject reject
>> > accept accept
>>
>> Thanks, but the second test ca
"Christos Georgiou" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Thu, 26 Jan 2006 17:09:18 GMT, rumours say that "Roger L. Cauvin"
> <[EMAIL PROTECTED]> might have written:
>
>>Thanks, but the second test case I listed contained a typo. It should
>>have
>>contained a sequence
Roger L. Cauvin wrote:
> > $ python test.py
> > gotexpected
> > ---
> > accept accept
> > reject reject
> > accept accept
> > reject reject
> > accept accept
>
> Thanks, but the second test case I listed contained a typo. It should have
> contained a sequence of three of the lette
"Christos Georgiou" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Thu, 26 Jan 2006 18:01:07 +0100, rumours say that "Fredrik Lundh"
> <[EMAIL PROTECTED]> might have written:
>
>>Roger L. Cauvin wrote:
>>
>>> Good suggestion. Here are some "test cases":
>>>
>>> "xyz123aaabbab" a
On Thu, 26 Jan 2006 17:09:18 GMT, rumours say that "Roger L. Cauvin"
<[EMAIL PROTECTED]> might have written:
>Thanks, but the second test case I listed contained a typo. It should have
>contained a sequence of three of the letter 'a'. The test cases should be:
>
>"xyz123aaabbab" accept
>"xyz123
"Christos Georgiou" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Thu, 26 Jan 2006 16:26:57 GMT, rumours say that "Roger L. Cauvin"
> <[EMAIL PROTECTED]> might have written:
>
>>"Christos Georgiou" <[EMAIL PROTECTED]> wrote in message
>>news:[EMAIL PROTECTED]
>
>>> On Thu, 26 Ja
"Christos Georgiou" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Thu, 26 Jan 2006 16:41:08 GMT, rumours say that "Roger L. Cauvin"
> <[EMAIL PROTECTED]> might have written:
>
>>Good suggestion. Here are some "test cases":
>>
>>"xyz123aaabbab" accept
>>"xyz123aabbaab" reject
>>
On Thu, 26 Jan 2006 18:01:07 +0100, rumours say that "Fredrik Lundh"
<[EMAIL PROTECTED]> might have written:
>Roger L. Cauvin wrote:
>
>> Good suggestion. Here are some "test cases":
>>
>> "xyz123aaabbab" accept
>> "xyz123aabbaab" reject
>> "xayz123aaabab" accept
>> "xaaayz123abab" reject
>> "xaa
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Roger L. Cauvin wrote:
>
>> Good suggestion. Here are some "test cases":
>>
>> "xyz123aaabbab" accept
>> "xyz123aabbaab" reject
>> "xayz123aaabab" accept
>> "xaaayz123abab" reject
>> "xaaayz123aaabab" accept
>
> $ more
On Thu, 26 Jan 2006 16:26:57 GMT in comp.lang.python, "Roger L.
Cauvin" <[EMAIL PROTECTED]> wrote:
>"Christos Georgiou" <[EMAIL PROTECTED]> wrote in message
>news:[EMAIL PROTECTED]
[...]
>> Is this what you mean?
>>
>> ^[^a]*(a{3})(?:[^a].*)?$
>
>Close, but the pattern should allow "arbitrary seq
Roger L. Cauvin wrote:
> Good suggestion. Here are some "test cases":
>
> "xyz123aaabbab" accept
> "xyz123aabbaab" reject
> "xayz123aaabab" accept
> "xaaayz123abab" reject
> "xaaayz123aaabab" accept
$ more test.py
import re
print "gotexpected"
print "-- "
testsuite = (
("x
On Thu, 26 Jan 2006 16:41:08 GMT, rumours say that "Roger L. Cauvin"
<[EMAIL PROTECTED]> might have written:
>Good suggestion. Here are some "test cases":
>
>"xyz123aaabbab" accept
>"xyz123aabbaab" reject
>"xayz123aaabab" accept
>"xaaayz123abab" reject
>"xaaayz123aaabab" accept
Applying my last
"Alex Martelli" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Tim Chase <[EMAIL PROTECTED]> wrote:
>
>> > Sorry for the confusion. The correct pattern should reject
>> > all strings except those in which the first sequence of the
>> > letter 'a' that is followed by the letter 'b'
On Thu, 26 Jan 2006 16:26:57 GMT, rumours say that "Roger L. Cauvin"
<[EMAIL PROTECTED]> might have written:
>"Christos Georgiou" <[EMAIL PROTECTED]> wrote in message
>news:[EMAIL PROTECTED]
>> On Thu, 26 Jan 2006 14:09:54 GMT, rumours say that "Roger L. Cauvin"
>> <[EMAIL PROTECTED]> might have
Christoph Conrad <[EMAIL PROTECTED]> wrote:
> Hello Roger,
>
> > since the length of the first sequence of the letter 'a' is 2. Yours
> > accepts it, right?
>
> Yes, i misunderstood your requirements. So it must be modified
> essentially to that what Tim Chase wrote:
>
> m = re.search('^[^a
"Peter Hansen" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Roger L. Cauvin wrote:
>> Sorry for the confusion. The correct pattern should reject all strings
>> except those in which the first sequence of the letter 'a' that is
>> followed by the letter 'b' has a length of exact
"Tim Chase" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>>>r = re.compile("[^a]*a{3}b+(a+b*)*")
>>>matches = [s for s in listOfStringsToTest if r.match(s)]
>>
>> Wow, I like it, but it allows some strings it shouldn't. For example:
>>
>> "xyz123aabbaaab"
>>
>> (It skips over the t
Roger L. Cauvin wrote:
> Sorry for the confusion. The correct pattern should reject all strings
> except those in which the first sequence of the letter 'a' that is followed
> by the letter 'b' has a length of exactly three.
>
> Hope that's clearer . . . .
Examples are a *really* good way to c
>>r = re.compile("[^a]*a{3}b+(a+b*)*")
>>matches = [s for s in listOfStringsToTest if r.match(s)]
>
> Wow, I like it, but it allows some strings it shouldn't. For example:
>
> "xyz123aabbaaab"
>
> (It skips over the two-letter sequence of 'a' and matches 'bbaaab'.)
Anchoring it to the beginnin
"Christos Georgiou" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Thu, 26 Jan 2006 14:09:54 GMT, rumours say that "Roger L. Cauvin"
> <[EMAIL PROTECTED]> might have written:
>
>>Say I have some string that begins with an arbitrary sequence of
>>characters
>>and then alternates
"Tim Chase" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>> Sorry for the confusion. The correct pattern should reject
>> all strings except those in which the first sequence of the
>> letter 'a' that is followed by the letter 'b' has a length of
>> exactly three.
>
> Ah...a little
Hallo Alex,
>> r = re.compile("[^a]*a{3}b+(a+b*)*") matches = [s for s in
>> listOfStringsToTest if r.match(s)]
> Unfortunately, the OP's spec is even more complex than this, if we are
> to take to the letter what you just quoted; e.g. aazaaab SHOULD match,
Then it's again "a{3}b", isn't it?
Fr
Tim Chase <[EMAIL PROTECTED]> wrote:
> > Sorry for the confusion. The correct pattern should reject
> > all strings except those in which the first sequence of the
> > letter 'a' that is followed by the letter 'b' has a length of
> > exactly three.
>
> Ah...a little more clear.
>
> r = re
> Sorry for the confusion. The correct pattern should reject
> all strings except those in which the first sequence of the
> letter 'a' that is followed by the letter 'b' has a length of
> exactly three.
Ah...a little more clear.
r = re.compile("[^a]*a{3}b+(a+b*)*")
matches = [s
"Sybren Stuvel" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Roger L. Cauvin enlightened us with:
>> I'm looking for a regular expression that matches the first, and
>> only the first, sequence of the letter 'a', and only if the length
>> of the sequence is exactly 3.
>
> Your req
Hello Roger,
> since the length of the first sequence of the letter 'a' is 2. Yours
> accepts it, right?
Yes, i misunderstood your requirements. So it must be modified
essentially to that what Tim Chase wrote:
m = re.search('^[^a]*a{3}b', 'xyz123aabbaaab')
Best wishes from germany,
Christo
On Thu, 26 Jan 2006 14:09:54 GMT, rumours say that "Roger L. Cauvin"
<[EMAIL PROTECTED]> might have written:
>Say I have some string that begins with an arbitrary sequence of characters
>and then alternates repeating the letters 'a' and 'b' any number of times,
>e.g.
>
>"xyz123aaabbaaaba
"Alex Martelli" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Tim Chase <[EMAIL PROTECTED]> wrote:
> ...
>> I'm not quite sure what your intent here is, as the
>> resulting find would obviously be "aaa", of length 3.
>
> But that would also match ''; I think he wants negative
"Christoph Conrad" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello Roger,
>
>> I'm looking for a regular expression that matches the first, and only
>> the first, sequence of the letter 'a', and only if the length of the
>> sequence is exactly 3.
>
> import sys, re, os
>
> if _
Tim Chase <[EMAIL PROTECTED]> wrote:
...
> I'm not quite sure what your intent here is, as the
> resulting find would obviously be "aaa", of length 3.
But that would also match ''; I think he wants negative loobehind
and lookahead assertions around the 'aaa' part. But then there's the
spec
> Say I have some string that begins with an arbitrary
> sequence of characters and then alternates repeating the
> letters 'a' and 'b' any number of times, e.g.
> "xyz123aaabbaaabaaaabb"
>
> I'm looking for a regular expression that matches the
> first, and only the first, sequence
Roger L. Cauvin enlightened us with:
> I'm looking for a regular expression that matches the first, and
> only the first, sequence of the letter 'a', and only if the length
> of the sequence is exactly 3.
Your request is ambiguous:
1) You're looking for the first, and only the first, sequence of
Hello Roger,
> I'm looking for a regular expression that matches the first, and only
> the first, sequence of the letter 'a', and only if the length of the
> sequence is exactly 3.
import sys, re, os
if __name__=='__main__':
m = re.search('a{3}', 'xyz123aaabbaaaabaaabb')
print m
Say I have some string that begins with an arbitrary sequence of characters
and then alternates repeating the letters 'a' and 'b' any number of times,
e.g.
"xyz123aaabbaaabaaaabb"
I'm looking for a regular expression that matches the first, and only the
first, sequence of the letter 'a
84 matches
Mail list logo