There's $100 by PayPal in this fopr whoever solves this problem for me.
The first one who makes this work the best gets the money. If I use code
snippits out of other people's solution I'll give an extra $20 to the
other person I used a snippet from. And - I will share the solution for
free with everyone.
I just really need this.
Here what I need. I need to be able to read a text file containing
regular expressions on separate lines and turn the results into a big OR
regular expression. In other words - A file that looks like this:
String1
String2
String3
becomes (String1|String2|String3)
This code almost works:
if "$h_received:" matches "${readfile{/etc/exim/blockhosts}{|}}"
then
Add some header
endif
But - where it fails is - if there is a newline at the end it returns a
final | which kills it. Similarly - a blank line returns || in the
middle which also kills it.
It can't return (String1|String2||String3|)
The Solution seems to be applying ${sg} to the results and I have tried
that and came very close to actually working. But due to "" and multiple
levels of escaping I just gave up in frustration. Sometimes I'm just not
very good at this.
The part I need for you to write and test to make sure it works is the
part after "matches".
At a minimum, it can't return anything with a trailing "|" or a "||" in
the middle. Thus blank lines or lines that look blank (spaces ot tabs
only) have to be ignored.
Ideally - Lines that start with # would also be ignored.
A test file would look like this:
farm.*sex
^.*porn-site1
^.*porn-site2
# Comment to ignore followed by a blank line to also ignore
spam-site1
^.*spam-site2
^.*spam-site[0-9]{1,3}
#End - this line is ignored
So - who wants to make a little money and get this working? Here's some
of the code snippits that I was sent a long time ago when I last gave up:
${sg{ outer sg
${sg{ inner sg ) operand
${readfile{/file}{|}} operand for inner sg ) for
} end of operand ) outer
{\\|\$} match | at end ) sg
{} replace with nothing )
} end of inner sg )
} end operand for outer sg
{\\|\\|} match ||
{|} replace with |
}
if "${local_part:$h_From:}@${domain:$h_From:}" matches "${sg\
{${sg\
{${readfile{/etc/exim/x}{|}}}\
{#.*?\\\\|}\
{}\
}}\
{(\\\\|)\\\\|}\
{$1}\
}"
then
endif