Re: [Tutor] need help with a regular expression

2008-06-28 Thread Kelie
Mark Tolonen gmail.com> writes: > re.compile(r'^_{0,3}[A-Z](?:[A-Z0-9]|-(?!-))*[A-Z0-9]$') # if rule 4 is an > additional letter or digit > re.compile(r'^_{0,3}[A-Z](?:[A-Z0-9]|-(?!-))*(? single-letter strings are allowed > Mark, single-letter strings are allowed and your regular expression w

Re: [Tutor] need help with a regular expression

2008-06-28 Thread Kelie
Dick Moores gmail.com> writes: > I'm not sure of your 5th condition. Do you mean, "A hyphen should not > be immediately followed by a hyphen"? Could you give examples of what > you will permit, and will not permit? Dick, your are correct. A hyphen should not be immediately followed by a hyphen.

Re: [Tutor] need help with a regular expression

2008-06-28 Thread Mark Tolonen
"Kelie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hello, I'm trying to write a regular expression to filter strings that meet the following criteria: 1. Starts with 0-3 underscores; 2. Followed by one letter; 3. Then followed by 0 or more letters or digits or hyphens('-'), 4

Re: [Tutor] need help with a regular expression

2008-06-28 Thread Lie Ryan
On Sat, 2008-06-28 at 17:39 +0200, Andre Engels wrote: > On Sat, Jun 28, 2008 at 3:21 PM, Lie Ryan <[EMAIL PROTECTED]> wrote: > > > > I think > > > > > > _{0,3}[A-Z](\-?[A-Z0-9])+ > > > > > > will do what you are looking for. > > > > That, doesn't allow single hyphen, which his requirement al

Re: [Tutor] need help with a regular expression

2008-06-28 Thread Andre Engels
On Sat, Jun 28, 2008 at 3:21 PM, Lie Ryan <[EMAIL PROTECTED]> wrote: > > I think > > > > _{0,3}[A-Z](\-?[A-Z0-9])+ > > > > will do what you are looking for. > > That, doesn't allow single hyphen, which his requirement allowed as long > as it (the hypehn) is not as the first or last character.

Re: [Tutor] need help with a regular expression

2008-06-28 Thread Lie Ryan
>> Hello, >> >> I'm trying to write a regular expression to filter strings that meet > the >> following criteria: >> >> 1. Starts with 0-3 underscores; >> 2. Followed by one letter; >> 3. Then followed by 0 or more letters or digits or hyphens('-'), >> 4. Ends with one letter or digit;

Re: [Tutor] need help with a regular expression

2008-06-28 Thread Andre Engels
On Sat, Jun 28, 2008 at 11:15 AM, Kelie <[EMAIL PROTECTED]> wrote: > Hello, > > I'm trying to write a regular expression to filter strings that meet the > following criteria: > > 1. Starts with 0-3 underscores; > 2. Followed by one letter; > 3. Then followed by 0 or more letters or digits or hyphen

Re: [Tutor] need help with a regular expression

2008-06-28 Thread Lie Ryan
Filter it. Use two re, one the one you've made, the other the double hyphen filter: pat2 = re.compile('.*?\-\-.*?') If the string matches this re, then the string is rejected, if it DOES NOT match (i.e. pat2.match('blah') returns None, i.e. if not pat2.match('blah')), then it is accepted. btw: Y

Re: [Tutor] need help with a regular expression

2008-06-28 Thread Dick Moores
On Sat, Jun 28, 2008 at 2:15 AM, Kelie <[EMAIL PROTECTED]> wrote: > Hello, > > I'm trying to write a regular expression to filter strings that meet the > following criteria: > > 1. Starts with 0-3 underscores; > 2. Followed by one letter; > 3. Then followed by 0 or more letters or digits or hyphens

[Tutor] need help with a regular expression

2008-06-28 Thread Kelie
Hello, I'm trying to write a regular expression to filter strings that meet the following criteria: 1. Starts with 0-3 underscores; 2. Followed by one letter; 3. Then followed by 0 or more letters or digits or hyphens('-'), 4. Ends with one letter or digit; and 5. There should not be more than o