A regular expression (regexp) is a text string that describes some set of strings.
Functions that handle regular expressions, based on GNU regexp-0.12, have been implemented (for more details, see the GNU documentation about regexp rules).
The functions available from Search menu provide search forward or backward and replace. Each of them prompts a dialog box to get the target regexp.
Regular expressions are composed of characters and operators that match one or more characters. Here is an abstract of commons operators:
|
matches one of a choice of regular
expressions.
[...]
matches one item of a list.
[^...]
matches a single character not
represented by one of the list items.
(...)
treats any number of other operators
(i.e. subexpressions) as a unit.
\
digit matches a specified preceding group.
^
matches the beginning of line.
$
matches the end of line.
Smac provides the following functions:
returns the position of the next regular expression regexp, or -1 if regexp has not been found, or -2 if regexp is not valid.
returns the position of the previous regular expression regexp, or -1 if regexp has not been found, or -2 if regexp is not valid.
returns the beginning position of the substring n of the regexp found by the previous search call to a regexp.
returns the end position of the substring n of the regexp found by the previous search call to a regexp.
replaces the regular expression regexp with the string newstring. If the argument regexp is ommited, the previous search call to a regexp is used. It returns 1 on success else 0.
Example: