Contents | < Browse | Browse >
Searching for regular expressions
=================================

   Searching for regular expressions is done with the built-in `regexp':

     regexp(STRING, REGEXP, opt REPLACEMENT)

which searches for REGEXP in STRING.  The syntax for regular
expressions is the same as in GNU Emacs.  (emacs)Regexps

   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', `<Qw*')
     =>-1

   If REPLACEMENT is supplied, `regexp' changes the expansion to this
argument, with `&' substituted by STRING, and `N' substituted by the
text matched by the Nth parenthesized sub-expression of REGEXP, `0'
being the text the entire regular expression matched.

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