The Bat!

A Compilation of Regex-Based Macros created by various users of The Bat!

The Bat!

Back to The Bat! FAQ / How-Do-I

You are caller No. counter

During the life of the TB! user discussion lists, regular expression (regex) based macros have been created to be used in message templates. These have greatly enhanced the scope of the automated aspects of e-mail messaging that TB! already offers through 'packaged' macros. This page offers to all TB! users, a compilation of most of these macros created to date.

Regex macros involve the use of regular expressions which must be written out as a single line of text for them to function as they should. They must be used exactly as shown, i.e., as a single line of text when indicated.

Quick templates and the %QINCLUDE="" macro help greatly in the use of these regex-based macros. It is a good idea to create a quick template for each of the macros you wish to use singly or in combination during your e-mail management; pasting the regex macro *as is*, in the quick template editor field. You may then use these macros in other templates, using the %QINCLUDE="[qt handle]" macro.

For example, here's a reply template for the TB! user discussion list:


%QINCLUDE="subintro" points to a quick template with the handle name "subintro". This template contains a regex macro that generates an introduction which in turn contains the original message date and time as it appears in the RFC headers.

The %QINCLUDE="sigstrip" also points to a quick template containing a regex macro. This regex macro trims the quoted text of all signature related material. Also mentioned is %QINCLUDE="ListTo", which points to a Quick Template with the handle "ListTo". These macros will be discussed later.

Including the original message date in replies:

When generating original message dates and times with the provided TB! macros %ODATE\%ODATELONG and %OTIME\%OTIMELONG, the original message dates and times are converted to your systems own time zone settings. There are many who would prefer if this was not done. A regex based macro was created to extract the original message date and time from a messages RFC headers. Here it is:


If you wish to generate only the original message time, you can use the following modification of the macro using the regex subpattern output support (the %SUBPATT="" macro):


A practical example of how this regex macro may be used with other macros to produce an introduction goes like this:

On%SUBPATT="2", at %SUBPATT="3" [GMT%SUBPATT="4"] you wrote:'

It will generate an output like this:

Hi Jasper,
On Sun, 29 Oct 2000 10:41:17 -0800 you wrote:

The original message date is used instead of the one corrected to your system's time zone settings.

Finally, to roll it all together into a full message attribution line:

On%SUBPATT="2", at %SUBPATT="3" [GMT%SUBPATT="4"] %-
(which was %OTIME where I live) you wrote:'

It will generate an output like this:

Hi Jasper,
On Sun, 29 Oct 2000 10:41:17 -0800 (which was 18:41 where
I live) you wrote:

Cleaning up message subject headers:

Have you ever wanted to automatically delete the extra prefixes that are included in message subjects when replying to them? These redundant prefixes are often seen on discussion lists and in chain letters, examples being:

Fw: Fwd: FW: Fwd Fw: This Is Scary!! The Phone Will Ring Right After You
Re: [bidgeneral] Re: Suspicions of BID blocking Win2k internet connection
If you place the following macro in your reply templates your messages will always be generated with the format "Re:<message subject>" without any extra prefixing:


If you wish to use the 'cleaned' subject in reply message introductions, insert the following regex macro where you would wish to insert the 'cleaned' subject (remember that a quick template and a %QINCLUDE macro would help a lot here):


Automatically stripping out signatures and advertisements:

As PGP becomes more widely used, we will come across PGP clear-signed messages more often. Also, messages will frequently have long signatures or signatures with other additions such as discussion list links at the end of list messages, and Yahoo-groups and MSN text-based ads.

Wouldn't it be nice to hit the reply button and have the entire message body quoted, with all the unwanted signatures and ads automatically trimmed out? Well, you can do this in TB! with the use of the following regex macro (replace the %QUOTES macro with it):

[MSN enhanced by Silviu Cojocaru]
%quotes='%SETPATTREGEXP="(?is)((\s*)?\n?-----BEGIN PGP %-
\n-----BEGIN PGP SIGNATURE.*s?\n|%-
\n+Get your FREE download|%-

If you do not have Yahoo-groups banner ad problems and wish to automatically trim only signatures which are preceded by common signature delimiters then you may use the following macro:

%quotes='%SETPATTREGEXP="(?is)((\s*)?\n?-----BEGIN PGP %-

Special addressing:

Including the name of the person to whom you're replying in a discussion list messages 'To:' address is useful. It allows the list readers to be able to tell, by looking at the headers, which list member the message is a reply to. A regex macro has been crafted which may be used to generate this addressing format, no matter which discussion list it's being used for. Call it a master reply address template for discussion lists, if you will. :-) Here it is:

%TO=''%TO='"%OFROMNAME on %-
%SubPatt=#1#" <%OREPLYADDR>'