>how to write a variable regex

it takes you two and a half cent.

<<<^(?=.*?\nfrom:.*?\@(domain1|TheirOrgDomain|domain3|redcross
))(?=.+?\nto:.*?...@help\.domain\.org)>>>

the '<<<.....>>>' prevents assp from optimizing this single line or 
instead of '<<<' and '>>>' write  'assp-do-not-optimize-regex' at the 
first line of the file

The regex must be the first regex in the file - and it must be written in 
one line!

short description:

scanning from the begin - searching for 'from: ... [valid domains]' and 
captures the domain name - jump back to the begin - searching for 'to: ... 
[the before captured domain [email protected]

hope you see - this part contains the domain names separated by  ' |'

(domain1|TheirOrgDomain|domain3|redcross)

I've tested the regex with the following perl lines. The order of the 
lines with the 'from' and 'to' could be reverse - so $d is for 'from - to' 
$e is for 'to - from'

$d = "a\r\nfrom: \"test\" <[email protected]> \r\nany line\r\nother 
line\r\nto: \"test2\" <[email protected]>\r\n";
$e = "a\r\nto: \"test2\" <[email protected]>\r\nany line\r\nother 
line\r\nfrom: \"test\" <[email protected]> \r\n";

print 'd' if $d =~ 
/^(?=.*?\nfrom:.*?\@(domain1|domain2|domain3|domain4))(?=.+?\nto:.*?...@help\.domain\.org)/s;
print 'e' if $e =~ 
/^(?=.*?\nfrom:.*?\@(domain1|domain2|domain3|domain4))(?=.+?\nto:.*?...@help\.domain\.org)/s;

Thomas



Von:    K Post <[email protected]>
An:     [email protected]
Datum:  23.12.2010 14:25
Betreff:        [Assp-test] Regex Help - variables




This is absolutely NOT urgent....

We have a subdomain used for a group (@help.domain.org).  Without going 
into
too much detail, we setup a system for outside organizations to 
communicate
with this help subdomain using specific inbound addresses based on their
domain. For example, if we're working with the Red Cross, someone with
[email protected] would email [email protected].  Someone
from another org would email [email protected].

I'd like to setup a regex to consider an address whitelisted so long as 
the
userpart exactly matches the subdomain.   In the above examle, the message
should get through since redcross.org is the sender domain and the to
address user part is redcross.

I'm just unsure how to write a variable regex that checks this.  I do
remember that I'll need two, one in case the from comes first, one in case
the to is first, but beyond that, I don't know how to match what's found
first with the second part.

Thanks
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, 
and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Assp-test mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/assp-test




DISCLAIMER:
*******************************************************
This email and any files transmitted with it may be confidential, legally 
privileged and protected in law and are intended solely for the use of the 

individual to whom it is addressed.
This email was multiple times scanned for viruses. There should be no 
known virus in this email!
*******************************************************


------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Assp-test mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/assp-test

Reply via email to