A substitution pattern is a structure (defined in interp.h) :
typedef struct SUBST_PAT { char orig; subst_delim delim; pfi_char F; } subst_pat;
Here delim is a delimiter structure :
typedef struct SUBST_DELIM { char begin; char end; } subst_delim;
and F is a pfi_char function :
typedef void (*pfi_char)(char *, char **, flow_data *);
For instance when we use string variables (cf. 4.4) the members begin and end of delim (the underlying delimiter structure) are respectively [ and ], the member orig of the substitution pattern is $, and F is a function that replaces the name of the string variable by its contents.
Five substitution patterns are recognized by the interpreter :
#() : this is used to substitute arguments inside command files or programs (cf. 4.2).
%() : this is used to insert floating point numbers (cf. 4.3.2).
!() : this is used to insert integers (cf. 4.3.2).
$() : this is used to insert character strings defined by question files (cf. 4.8.3 and 8).
$[] : this is used to insert the content of string variables (cd. 4.4).
The corresponding substitution patterns are Subst_Pat[0] to Subst_Pat[4] (they are defined in the function default_Subst_Pat in interp.c).
It is possible to use nested substitution : for instance $[XX%(i+$[V])__!(x$(2))] is correct.