Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 828a0bd

Browse files
committed
count() now has a 4th parameter too. Also rephrased the docs for find
to use the same, better words to explain start/end.
1 parent 871cf16 commit 828a0bd

2 files changed

Lines changed: 18 additions & 24 deletions

File tree

Doc/lib/libstring.tex

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,11 @@ \section{Standard Module \sectcode{string}}
110110
\end{funcdesc}
111111

112112
\begin{funcdesc}{find}{s\, sub\optional{\, start\optional{\,end}}}
113-
Return the lowest index in \var{s} not smaller than \var{start} and not
114-
greater than \var{end} where the substring \var{sub} is found. Return
115-
\code{-1} when \var{sub} does not occur as a substring of \var{s} with
116-
index at least \var{start} and less than \var{end}.
117-
If \var{start} is omitted, it defaults to \code{0}. If \var{start} is
118-
negative, \code{len(\var{s})} is added.
119-
If \var{end} is omitted, it defaults to \code{len(\var{s})}. If
120-
\var{end} is negative, \code{len(\var{s})} is added.
113+
Return the lowest index in \var{s} where the substring \var{sub} is
114+
found such that \var{sub} is wholly contained in
115+
\code{\var{s}[\var{start}:\var{end}]}. Return -1 on failure.
116+
Defaults for \var{start} and \var{end} and interpretation of negative
117+
values is the same as for slices.
121118
\end{funcdesc}
122119

123120
\begin{funcdesc}{rfind}{s\, sub\optional{\, start\optional{\,end}}}
@@ -134,11 +131,11 @@ \section{Standard Module \sectcode{string}}
134131
not found.
135132
\end{funcdesc}
136133

137-
\begin{funcdesc}{count}{s\, sub\optional{\, start}}
134+
\begin{funcdesc}{count}{s\, sub\optional{\, start\optional{\,end}}}
138135
Return the number of (non-overlapping) occurrences of substring
139-
\var{sub} in string \var{s} with index at least \var{start}.
140-
If \var{start} is omitted, it defaults to \code{0}. If \var{start} is
141-
negative, \code{len(\var{s})} is added.
136+
\var{sub} in string \code{\var{s}[\var{start}:\var{end}]}.
137+
Defaults for \var{start} and \var{end} and interpretation of negative
138+
values is the same as for slices.
142139
\end{funcdesc}
143140

144141
\begin{funcdesc}{lower}{s}

Doc/libstring.tex

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,11 @@ \section{Standard Module \sectcode{string}}
110110
\end{funcdesc}
111111

112112
\begin{funcdesc}{find}{s\, sub\optional{\, start\optional{\,end}}}
113-
Return the lowest index in \var{s} not smaller than \var{start} and not
114-
greater than \var{end} where the substring \var{sub} is found. Return
115-
\code{-1} when \var{sub} does not occur as a substring of \var{s} with
116-
index at least \var{start} and less than \var{end}.
117-
If \var{start} is omitted, it defaults to \code{0}. If \var{start} is
118-
negative, \code{len(\var{s})} is added.
119-
If \var{end} is omitted, it defaults to \code{len(\var{s})}. If
120-
\var{end} is negative, \code{len(\var{s})} is added.
113+
Return the lowest index in \var{s} where the substring \var{sub} is
114+
found such that \var{sub} is wholly contained in
115+
\code{\var{s}[\var{start}:\var{end}]}. Return -1 on failure.
116+
Defaults for \var{start} and \var{end} and interpretation of negative
117+
values is the same as for slices.
121118
\end{funcdesc}
122119

123120
\begin{funcdesc}{rfind}{s\, sub\optional{\, start\optional{\,end}}}
@@ -134,11 +131,11 @@ \section{Standard Module \sectcode{string}}
134131
not found.
135132
\end{funcdesc}
136133

137-
\begin{funcdesc}{count}{s\, sub\optional{\, start}}
134+
\begin{funcdesc}{count}{s\, sub\optional{\, start\optional{\,end}}}
138135
Return the number of (non-overlapping) occurrences of substring
139-
\var{sub} in string \var{s} with index at least \var{start}.
140-
If \var{start} is omitted, it defaults to \code{0}. If \var{start} is
141-
negative, \code{len(\var{s})} is added.
136+
\var{sub} in string \code{\var{s}[\var{start}:\var{end}]}.
137+
Defaults for \var{start} and \var{end} and interpretation of negative
138+
values is the same as for slices.
142139
\end{funcdesc}
143140

144141
\begin{funcdesc}{lower}{s}

0 commit comments

Comments
 (0)