User manual

mikroPascal PRO for PIC32
MikroElektronika
591
strstr
strcspn
strpbrk
strrchr
Prototype
function strstr(var s1, s2 : string) : word;
Description The function locates the rst occurrence of the string s2 in the string s1 (excluding the terminating
null character).
The function returns a number indicating the position of the rst occurrence of s2 in s1; if no string was
found, the function returns 0xFFFF. If s2 is a null string, the function returns 0.
Example
txt := ‘mikroElektronika’;
txt_sub := ‘mikr’;
res := strstr(txt_sub,txt);
Prototype
function strcspn(var s1, s2 : string) : word;
Description The function searches the string s1 for any of the characters in the string s2.
The function returns the index of the rst character located in s1 that matches any character in s2. If
the rst character in s1 matches a character in s2, a value of 0 is returned. If there are no matching
characters in s1, the length of the string is returned (not including the terminating null character).
Example
txt := ‘mikroElektronika’;
txt_sub := ‘mikr’;
res := strcspn(txt_sub,txt);
Prototype
function strpbrk(var s1, s2 : string) : word;
Description The function searches s1 for the rst occurrence of any character from the string s2. The null
terminator is not included in the search. The function returns an index of the matching character in s1.
If s1 contains no characters from s2, the function returns 0xFFFF.
Example
txt := ‘mikroElektronika’;
txt_sub := ‘mikr’;
res := strpbrk(txt_sub,txt);
Prototype
function strrchr(var s : string; ch : byte) : word;
Description The function searches the string s for the last occurrence of the character ch. The null character
terminating s is not included in the search. The function returns an index of the last ch found in s; if no
matching character was found, the function returns 0xFFFF.
Example
txt := ‘mikroElektronika’;
res = strrchr(txt,’k’); // returns the index of the ‘kcharacter of the ‘txt
string