[exim-dev] ${index}

Top Pagina
Delete this message
Reply to this message
Auteur: Mike Cardwell
Datum:  
Aan: exim-dev
Onderwerp: [exim-dev] ${index}
http://github.com/mikecardwell/Exim/commit/b4ef92d69ac58a46cbb0babb93d688267fbed443

Provides a ${index{string}{substring}} function to return the location
of a string within a string. Examples:

mike@snail:~/git/exim.build/src$ ./build-Linux-x86_64/exim -be
'${index{foobar}{oo}}'
1
mike@snail:~/git/exim.build/src$ ./build-Linux-x86_64/exim -be
'${index{foobar}{f}}'
0
mike@snail:~/git/exim.build/src$ ./build-Linux-x86_64/exim -be
'${index{foobar}{bar}}'
3
mike@snail:~/git/exim.build/src$ ./build-Linux-x86_64/exim -be
'${index{foobar}{woo}}'
-1
mike@snail:~/git/exim.build/src$ ./build-Linux-x86_64/exim -be
'${index{foobar}{}}'
-1
mike@snail:~/git/exim.build/src$

Use case: Check if the sender address is in the subject line:

condition = ${if >{${index{$h_Subject:}{$sender_address}}}{-1}}

You could use ${match} but then you'd have to worry about special regex
characters in the key such as '.'.

Comments?

I might add a case insensitive version too, "indexi" perhaps? If there
are no "that sucks" comments, I'll make the rest of the additions
regarding docs etc and let you know when it can be pulled.

-- 
Mike Cardwell - Perl/Java/Web developer, Linux admin, Email admin
Read my tech Blog -              https://secure.grepular.com/
Follow me on Twitter -           http://twitter.com/mickeyc
Hire me - http://cardwellit.com/ http://uk.linkedin.com/in/mikecardwell