|
LPC Library Functions: strsrch |
NAMEstrsrch() - search for substrings in a string SYNOPSISint strsrch( string str, string substr | int char, int n ); DESCRIPTIONstrsrch() searches for the first occurrence of the string `substr' in the string `str'. If the second argument is an integer, strsrch() will find the first character in 'str' matching 'char'. This is similar to the behavior of C's strchr()/strrchr(). If optional argument 'n' is an integer, strsrch() will find the nth occurrence of 'substr' and return the index of that occurrence's position in the string. For example:
> return strsrch("abcdabcdabcd","ab",3); // Find the third "ab"
Returns: 8
If 'n' is -1, strsrch() will find the rightmost occurrence of 'substr' in 'str'. The empty string or null value cannot be searched for; doing so will return -1. The integer offset of the match is returned. -1 is returned if there was no match. SEE ALSO |
|
Page design by Frank Jacquette & Tim Hollebeek Copyright (C) 1998 Tim Hollebeek & Frank Jacquette |
|