## version 2/111127 by Aaron Reed

Chapter - Macros for defining rules

To decide whether stripping (regex - an indexed text) is fruitful, even within words, only in the middle:
if even within words:
if replacing regex with "" is fruitful, even within words:
decide yes;
if only in the middle:
if replacing regex with "" is fruitful, only in the middle:
decide yes;
otherwise:
if replacing regex with "" is fruitful, decide yes;
decide no.

To decide whether replacing (regex - an indexed text) with (newstr - an indexed text) is fruitful, even within words, only in the middle:
let original be the reborn command;
if even within words:
replace the regular expression "[regex]" in reborn command with "[newstr]";
otherwise if only in the middle:
replace the regular expression "(?=(^\s)+)\b[regex]\b(?=(^\s)+)" in reborn command with "[newstr]";
otherwise:
replace the regular expression "\b[regex]\b" in reborn command with "[newstr]";
if original is not reborn command:
decide yes;
now reborn command is original;
decide no.

To decide whether input starts with (regex - an indexed text), even within words:
if even within words:
if reborn command exactly matches the regular expression "^[regex].*":
decide yes;
otherwise:
if reborn command exactly matches the regular expression "^[regex]\b.*":
decide yes;
decide no.

To decide whether input ends with (regex - an indexed text), even within words:
if even within words:
if reborn command exactly matches the regular expression ".*[regex]\$":
decide yes;
otherwise:
if reborn command exactly matches the regular expression ".*\b[regex]\$":
decide yes;
decide no.

To decide whether input contains (regex - an indexed text), even within words:
if even within words:
if reborn command matches the regular expression "[regex]":
decide yes;
otherwise:
if reborn command matches the regular expression "\b[regex]\b":
decide yes;
decide no.