]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) |
2 | .\" | |
93015253 | 3 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
c13182ef | 12 | .\" |
fea681da MK |
13 | .\" Since the Linux kernel and libraries are constantly changing, this |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
16 | .\" the use of the information contained herein. The author(s) may not | |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
c13182ef | 20 | .\" |
fea681da MK |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
fea681da MK |
24 | .\" |
25 | .\" References consulted: | |
26 | .\" Linux libc source code | |
27 | .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) | |
28 | .\" 386BSD man pages | |
29 | .\" Modified Sat Jul 24 17:56:43 1993 by Rik Faith (faith@cs.unc.edu) | |
30 | .\" Added history, aeb, 980113. | |
7257eeb8 | 31 | .\" 2005-05-05 mtk: added strcasestr() |
fea681da | 32 | .\" |
460495ca | 33 | .TH STRSTR 3 2015-08-08 "GNU" "Linux Programmer's Manual" |
fea681da | 34 | .SH NAME |
0778327e | 35 | strstr, strcasestr \- locate a substring |
fea681da MK |
36 | .SH SYNOPSIS |
37 | .nf | |
38 | .B #include <string.h> | |
68e4db0a | 39 | .PP |
fea681da | 40 | .BI "char *strstr(const char *" haystack ", const char *" needle ); |
68e4db0a | 41 | .PP |
b80f966b | 42 | .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" |
68e4db0a | 43 | .PP |
7257eeb8 | 44 | .B #include <string.h> |
68e4db0a | 45 | .PP |
7257eeb8 | 46 | .BI "char *strcasestr(const char *" haystack ", const char *" needle ); |
fea681da MK |
47 | .fi |
48 | .SH DESCRIPTION | |
60a90ecd MK |
49 | The |
50 | .BR strstr () | |
51 | function finds the first occurrence of the substring | |
46d8df8e MK |
52 | .I needle |
53 | in the string | |
54 | .IR haystack . | |
71d9e7ae | 55 | The terminating null bytes (\(aq\\0\(aq) are not compared. |
847e0d88 | 56 | .PP |
60a90ecd MK |
57 | The |
58 | .BR strcasestr () | |
59 | function is like | |
2777b1ca | 60 | .BR strstr (), |
7257eeb8 | 61 | but ignores the case of both arguments. |
47297adb | 62 | .SH RETURN VALUE |
7257eeb8 | 63 | These functions return a pointer to the beginning of the |
65b1e0ed | 64 | located substring, or NULL if the substring is not found. |
d51899bb | 65 | .SH ATTRIBUTES |
84452907 PH |
66 | For an explanation of the terms used in this section, see |
67 | .BR attributes (7). | |
68 | .TS | |
69 | allbox; | |
70 | lb lb lb | |
71 | l l l. | |
72 | Interface Attribute Value | |
73 | T{ | |
d51899bb | 74 | .BR strstr () |
84452907 PH |
75 | T} Thread safety MT-Safe |
76 | T{ | |
d51899bb | 77 | .BR strcasestr () |
84452907 PH |
78 | T} Thread safety MT-Safe locale |
79 | .TE | |
47297adb | 80 | .SH CONFORMING TO |
0f52343c MK |
81 | .BR strstr (): |
82 | POSIX.1-2001, POSIX.1-2008, C89, C99. | |
847e0d88 | 83 | .PP |
60a90ecd MK |
84 | The |
85 | .BR strcasestr () | |
c8f2dd47 | 86 | function is a nonstandard extension. |
0c2d0a66 MK |
87 | .\" .SH BUGS |
88 | .\" Early versions of Linux libc (like 4.5.26) would not allow | |
89 | .\" an empty | |
90 | .\" .I needle | |
91 | .\" argument for | |
92 | .\" .BR strstr (). | |
93 | .\" Later versions (like 4.6.27) work correctly, | |
94 | .\" and return | |
95 | .\" .IR haystack | |
96 | .\" when | |
97 | .\" .I needle | |
98 | .\" is empty. | |
47297adb | 99 | .SH SEE ALSO |
fea681da MK |
100 | .BR index (3), |
101 | .BR memchr (3), | |
3924b70d | 102 | .BR memmem (3), |
fea681da | 103 | .BR rindex (3), |
7257eeb8 | 104 | .BR strcasecmp (3), |
f0c34053 | 105 | .BR strchr (3), |
d095200e | 106 | .BR string (3), |
fea681da MK |
107 | .BR strpbrk (3), |
108 | .BR strsep (3), | |
109 | .BR strspn (3), | |
1709027c | 110 | .BR strtok (3), |
0a4f8b7b | 111 | .BR wcsstr (3) |