manpagez: man pages & more
info m4
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.4 Extracting substrings

Substrings are extracted with substr:

Builtin: substr (string, from, [length]

Expands to the substring of string, which starts at index from, and extends for length characters, or to the end of string, if length is omitted. The starting index of a string is always 0. The expansion is empty if there is an error parsing from or length, if from is beyond the end of string, or if length is negative.

The macro substr is recognized only with parameters.

substr(`gnus, gnats, and armadillos', `6')
⇒gnats, and armadillos
substr(`gnus, gnats, and armadillos', `6', `5')

Omitting from evokes a warning, but still produces output.

error-->m4:stdin:1: Warning: too few arguments to builtin `substr'
error-->m4:stdin:2: empty string treated as 0 in builtin `substr'

This document was generated on September 29, 2013 using texi2html 5.0.

© 2000-2018
Individual documents may contain additional copyright information.