Go to the first, previous, next, last section, table of contents.


Searching for regular expressions

Searching for regular expressions is done with the builtin regexp:

regexp(string, regexp, opt replacement)

which searches for regexp in string. The syntax for regular expressions is the same as in GNU Emacs. See section `Syntax of Regular Expressions' in The GNU Emacs Manual.

If replacement is omitted, regexp expands to the index of the first match of regexp in string. If regexp does not match anywhere in string, it expands to -1.

regexp(`GNUs not Unix', `\<[a-z]\w+')
=>5
regexp(`GNUs not Unix', `\<Q\w*')
=>-1

If replacement is supplied, regexp changes the expansion to this argument, with `\n' substituted by the text matched by the nth parenthesized sub-expression of regexp, `\&' being the text the entire regular expression matched.

regexp(`GNUs not Unix', `\w\(\w+\)$', `*** \& *** \1 ***')
=>*** Unix *** nix ***

The builtin macro regexp is recognized only when given arguments.


Go to the first, previous, next, last section, table of contents.