a little about regex

Fulvio fulvio at pc.jaring.my
Thu Oct 19 06:31:59 EDT 2006


On Wednesday 18 October 2006 23:05, Ant wrote:
>     allow = re.compile(r'.*(?<!\.com)\.my(>|$)')  # negative lookbehind
>     if allow.search(adr):
>         return True
>     return False

I'd point out that :
 allow = re.search(r'.*(?<!\.com)\.my(>|$)',adr)

Will do as yours, since the call to 're' class will do the compilation as here 
it's doing separately.

> Though having the explicit allow and deny expressions may make what's
> going on clearer than the fairly esoteric negative lookbehind.

This makes me think that your point is truly correct.
The option for my case is meant as  "deny all except those are specified". 
Also may go viceversa. Therefore I should refine the way the filtering act.
In fact the (temporarily) ignored score is the base of the method to be 
applied.
Obviously here mainly we are talking about email addresses, so my intention is 
like the mailfilter concept, which means the program may block an entire 
domain but some are allowed and all from ".my" are allowed but not those 
from ".com.my" (mostly annoying emails :P )

At the sum of the view I've considered a flexible programming as much as I'm 
thinking that may be published some time to benefit for multiplatform user as 
python is.
In such perspective I'm a bit curious to know if exist sites on the web where 
small program are welcomed and people like me can express all of their 
ignorance about the mode of using python. For such ignorance I may concour 
for the Nobel Price :)

Also the News Group doesn't contemplate the idea to split into beginners and 
high level programmers (HLP). Of course the HLP are welcome to discuss on 
such NG :).

F



More information about the Python-list mailing list