www.delorie.com/gnu/docs/m4/m4_52.html   search  
 
Buy GNU books!


GNU macro processor

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.2 Searching for substrings

Searching for substrings is done with index:

 
index(string, substring)

which expands to the index of the first occurrence of substring in string. The first character in string has index 0. If substring does not occur in string, index expands to `-1'.

 
index(`gnus, gnats, and armadillos', `nat')
=>7
index(`gnus, gnats, and armadillos', `dag')
=>-1

The builtin macro index is recognized only when given arguments.


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003