On Mon, Mar 11, 2002 at 02:26:42PM +0000, Matt Sergeant wrote:
> I think the original intention of the count was to make sure we had at
> least three upper case chars, in which case you could get away with:
> 
> /^([A-Z]|[^a-z])*?[A-Z]{3,}([A-Z]|[^a-z])*$/
> 
> That needs testing though to make sure it doesn't backtrack horribly (I
> don't think it will, but I could be wrong).

Why not simplify this a little bit?

/^[^a-z]*?[A-Z]{3}[^a-z]*$/


[^a-z] encompases [A-Z], so it's redundant in the front and back.

[A-Z]{3,} will just gobble up all upper-case chars, which isn't necessary
 since the closing [^a-z]* will gobble them up as well.  So go for the quick
 match and let the star expression clean up for you on the back-end.

There's no references to slow things down.

Backtracking is still an issue if there are a lot of upper-case chars in the
 string that aren't in a group of 3.


-- 
Randomly Generated Tagline:
"We are born naked, wet, and hungry. Then things get worse." - Zen Musings

_______________________________________________
Spamassassin-talk mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/spamassassin-talk

Reply via email to