1strfind(3GEN) String Pattern-Matching Library Functions strfind(3GEN)
2
3
4
6 strfind, strrspn, strtrns, str - string manipulations
7
9 cc [ flag ... ] file ... -lgen [ library ... ]
10 #include <libgen.h>
11
12 int strfind(const char *as1, const char *as2);
13
14
15 char *strrspn(const char *string, const char *tc);
16
17
18 char * strtrns(const char *string, const char *old, const char *new,
19 char *result);
20
21
23 The strfind() function returns the offset of the first occurrence of
24 the second string, as2, if it is a substring of string as1. If the
25 second string is not a substring of the first string strfind() returns
26 −1.
27
28
29 The strrspn() function trims chartacters from a string. It searches
30 from the end of string for the first character that is not contained in
31 tc. If such a character is found, strrspn() returns a pointer to the
32 next character; otherwise, it returns a pointer to string.
33
34
35 The strtrns() function transforms string and copies it into result.
36 Any character that appears in old is replaced with the character in
37 the same position in new. The new result is returned.
38
40 When compiling multithreaded applications, the _REENTRANT flag must be
41 defined on the compile line. This flag should only be used in multi‐
42 threaded applications.
43
45 Example 1 An example of the strfind() function.
46
47 /* find offset to substring "hello" within as1 */
48 i = strfind(as1, "hello");
49 /* trim junk from end of string */
50 s2 = strrspn(s1, "*?#$%");
51 *s2 = '\0';
52 /* transform lower case to upper case */
53 a1[] = "abcdefghijklmnopqrstuvwxyz";
54 a2[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
55 s2 = strtrns(s1, a1, a2, s2);
56
57
58
60 See attributes(5) for descriptions of the following attributes:
61
62
63
64
65 ┌─────────────────────────────┬─────────────────────────────┐
66 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
67 ├─────────────────────────────┼─────────────────────────────┤
68 │MT-Level │MT-Safe │
69 └─────────────────────────────┴─────────────────────────────┘
70
72 string(3C), attributes(5)
73
74
75
76SunOS 5.11 20 Jan 1999 strfind(3GEN)