Please enable JavaScript to view this site.

A-Shell Reference

When the |s type code is specified, setdef is treated as a regular expression which the field contents must match.

Note that unlike most or all of the other setdef cases, in this case, no leading or trailing delimiters are used, just the regular expression itself.

Also note that in general, regular expressions can match anywhere in the field, which means that the field could contain additional leading or trailing characters which don't have any connection with the pattern. Typically this is not what you intended. To force the expression to match at the start and/or end of the field, you may want to include the regular expression anchor characters ^ (start of field) and $ (end of field).  For example, let's say you want to only accept fields starting with an optional numeric digit and ending with a mandatory character in the range of a-z.  Now consider the following two regular expressions:

setdef = "\d?[a-z]"

setdef = "^\d?[a-z]$"

The first expression is close, but would match a field containing "a!", since the first part of the pattern (the numeric digit) is optional, the "a" matches the second part of the pattern, and there is nothing preventing additional characters after that.  The second version closes that loophole by forcing the start of the pattern to match at the start of the field, and the end of the pattern to match at the end of the field, eliminating the possibility of extra characters not envisioned by the pattern.