GNU Info

Info Node: (m4.info)Regexp

(m4.info)Regexp


Next: Substr Prev: Index Up: Text handling
Enter node , (file) or (file)node

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.  Note: Syntax of Regular
Expressions.

   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.


automatically generated by info2www version 1.2.2.9