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

Skip to content

Commit 0b3f951

Browse files
committed
Added capwords, splitx, and optional 3rd argument to split/splitx.
1 parent 7a7d5d8 commit 0b3f951

2 files changed

Lines changed: 42 additions & 10 deletions

File tree

Doc/lib/libregsub.tex

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ \section{Standard Module \sectcode{regsub}}
77
Warning: these functions are not thread-safe.
88

99
\renewcommand{\indexsubitem}{(in module regsub)}
10+
1011
\begin{funcdesc}{sub}{pat\, repl\, str}
1112
Replace the first occurrence of pattern \var{pat} in string
1213
\var{str} by replacement \var{repl}. If the pattern isn't found,
@@ -23,13 +24,28 @@ \section{Standard Module \sectcode{regsub}}
2324
\code{gsub('', '-', 'abc')} returns \code{'-a-b-c-'}.
2425
\end{funcdesc}
2526

26-
\begin{funcdesc}{split}{str\, pat\optional{\, retain}}
27+
\begin{funcdesc}{split}{str\, pat\optional{\, maxsplit}}
2728
Split the string \var{str} in fields separated by delimiters matching
2829
the pattern \var{pat}, and return a list containing the fields. Only
2930
non-empty matches for the pattern are considered, so e.g.
3031
\code{split('a:b', ':*')} returns \code{['a', 'b']} and
31-
\code{split('abc', '')} returns \code{['abc']}.
32-
If the optional \var{retain} argument is true, the separators are also
33-
inserted in the list, so e.g. \code{split('a:::b', ':*', 1)} returns
34-
\code{['a', ':::', 'b']}.
32+
\code{split('abc', '')} returns \code{['abc']}. The \var{maxsplit}
33+
defaults to 0. If it is nonzero, only \var{maxsplit} number of splits
34+
occur, and the remainder of the string is returned as the final
35+
element of the list.
36+
\end{funcdesc}
37+
38+
\begin{funcdesc}{splitx}{str\, pat\optional{\, maxsplit}}
39+
Split the string \var{str} in fields separated by delimiters matching
40+
the pattern \var{pat}, and return a list containing the fields as well
41+
as the separators. For example, \code{splitx('a:::b', ':*')} returns
42+
\code{['a', ':::', 'b']}. Otherwise, this function behaves the same
43+
as \code{split}.
44+
\end{funcdesc}
45+
46+
\begin{funcdesc}{capwords}{s\optional{\, pat}}
47+
Capitalize words separated by optional pattern \var{pat}. The default
48+
pattern uses any characters except letters, digits and underscores as
49+
word delimiters. Capitalization is done by changing the first
50+
character of each word to upper case.
3551
\end{funcdesc}

Doc/libregsub.tex

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ \section{Standard Module \sectcode{regsub}}
77
Warning: these functions are not thread-safe.
88

99
\renewcommand{\indexsubitem}{(in module regsub)}
10+
1011
\begin{funcdesc}{sub}{pat\, repl\, str}
1112
Replace the first occurrence of pattern \var{pat} in string
1213
\var{str} by replacement \var{repl}. If the pattern isn't found,
@@ -23,13 +24,28 @@ \section{Standard Module \sectcode{regsub}}
2324
\code{gsub('', '-', 'abc')} returns \code{'-a-b-c-'}.
2425
\end{funcdesc}
2526

26-
\begin{funcdesc}{split}{str\, pat\optional{\, retain}}
27+
\begin{funcdesc}{split}{str\, pat\optional{\, maxsplit}}
2728
Split the string \var{str} in fields separated by delimiters matching
2829
the pattern \var{pat}, and return a list containing the fields. Only
2930
non-empty matches for the pattern are considered, so e.g.
3031
\code{split('a:b', ':*')} returns \code{['a', 'b']} and
31-
\code{split('abc', '')} returns \code{['abc']}.
32-
If the optional \var{retain} argument is true, the separators are also
33-
inserted in the list, so e.g. \code{split('a:::b', ':*', 1)} returns
34-
\code{['a', ':::', 'b']}.
32+
\code{split('abc', '')} returns \code{['abc']}. The \var{maxsplit}
33+
defaults to 0. If it is nonzero, only \var{maxsplit} number of splits
34+
occur, and the remainder of the string is returned as the final
35+
element of the list.
36+
\end{funcdesc}
37+
38+
\begin{funcdesc}{splitx}{str\, pat\optional{\, maxsplit}}
39+
Split the string \var{str} in fields separated by delimiters matching
40+
the pattern \var{pat}, and return a list containing the fields as well
41+
as the separators. For example, \code{splitx('a:::b', ':*')} returns
42+
\code{['a', ':::', 'b']}. Otherwise, this function behaves the same
43+
as \code{split}.
44+
\end{funcdesc}
45+
46+
\begin{funcdesc}{capwords}{s\optional{\, pat}}
47+
Capitalize words separated by optional pattern \var{pat}. The default
48+
pattern uses any characters except letters, digits and underscores as
49+
word delimiters. Capitalization is done by changing the first
50+
character of each word to upper case.
3551
\end{funcdesc}

0 commit comments

Comments
 (0)