Skip to content

Commit bde25e9

Browse files
committed
Merge branch 'maint'
2 parents df7c8a7 + fbac408 commit bde25e9

4 files changed

Lines changed: 67 additions & 147 deletions

File tree

lib/stdlib/src/string.erl

Lines changed: 21 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ _Example:_
355355
```erlang
356356
1> Reverse = string:reverse(unicode:characters_to_nfd_binary("ÅÄÖ")).
357357
[[79,776],[65,776],[65,778]]
358-
2> io:format("~ts~n",[Reverse]).
359-
ÖÄÅ
358+
2> io:format("%% ~ts~n",[Reverse]).
359+
%% ÖÄÅ
360360
```
361361
""".
362362
-doc(#{group => <<"Functions">>,since => <<"OTP 20.0">>}).
@@ -445,10 +445,10 @@ _Example:_
445445
```erlang
446446
1> string:pad(<<"He̊llö"/utf8>>, 8).
447447
[<<72,101,204,138,108,108,195,182>>,32,32,32]
448-
2> io:format("'~ts'~n",[string:pad("He̊llö", 8, leading)]).
449-
' He̊llö'
450-
3> io:format("'~ts'~n",[string:pad("He̊llö", 8, both)]).
451-
' He̊llö '
448+
2> io:format("%% '~ts'~n",[string:pad("He̊llö", 8, leading)]).
449+
%% ' He̊llö'
450+
3> io:format("%% '~ts'~n",[string:pad("He̊llö", 8, both)]).
451+
%% ' He̊llö '
452452
```
453453
""".
454454
-doc(#{group => <<"Functions">>,since => <<"OTP 20.0">>}).
@@ -543,9 +543,9 @@ Returns a string where any trailing `\n` or `\r\n` have been removed from
543543
_Example:_
544544

545545
```erlang
546-
182> string:chomp(<<"\nHello\n\n">>).
546+
1> string:chomp(<<"\nHello\n\n">>).
547547
<<"\nHello">>
548-
183> string:chomp("\nHello\r\r\n").
548+
2> string:chomp("\nHello\r\r\n").
549549
"\nHello\r"
550550
```
551551
""".
@@ -583,13 +583,13 @@ taken.
583583
_Example:_
584584

585585
```erlang
586-
5> string:take("abc0z123", lists:seq($a,$z)).
586+
1> string:take("abc0z123", lists:seq($a,$z)).
587587
{"abc","0z123"}
588-
6> string:take(<<"abc0z123">>, lists:seq($0,$9), true, leading).
588+
2> string:take(<<"abc0z123">>, lists:seq($0,$9), true, leading).
589589
{<<"abc">>,<<"0z123">>}
590-
7> string:take("abc0z123", lists:seq($0,$9), false, trailing).
590+
3> string:take("abc0z123", lists:seq($0,$9), false, trailing).
591591
{"abc0z","123"}
592-
8> string:take(<<"abc0z123">>, lists:seq($a,$z), true, trailing).
592+
4> string:take(<<"abc0z123">>, lists:seq($a,$z), true, trailing).
593593
{<<"abc0z">>,<<"123">>}
594594
```
595595
""".
@@ -661,7 +661,7 @@ tested for equality.
661661
_Example:_
662662

663663
```erlang
664-
2> string:lowercase(string:uppercase("Michał")).
664+
1> string:lowercase(string:uppercase("Michał")).
665665
"michał"
666666
```
667667
""".
@@ -746,8 +746,8 @@ _Example:_
746746

747747
```erlang
748748
1> {I1,Is} = string:to_integer("33+22"),
749-
1> {I2,[]} = string:to_integer(Is),
750-
1> I1-I2.
749+
{I2,[]} = string:to_integer(Is),
750+
I1-I2.
751751
11
752752
2> string:to_integer("0.5").
753753
{0,".5"}
@@ -787,8 +787,8 @@ _Example:_
787787

788788
```erlang
789789
1> {F1,Fs} = string:to_float("1.0-1.0e-1"),
790-
1> {F2,[]} = string:to_float(Fs),
791-
1> F1+F2.
790+
{F2,[]} = string:to_float(Fs),
791+
F1+F2.
792792
0.9
793793
2> string:to_float("3/2=1.5").
794794
{error,no_float}
@@ -871,11 +871,11 @@ parts. `Where`, default `leading`, indicates whether the `leading`, the
871871
_Example:_
872872

873873
```erlang
874-
0> string:split("ab..bc..cd", "..").
874+
1> string:split("ab..bc..cd", "..").
875875
["ab","bc..cd"]
876-
1> string:split(<<"ab..bc..cd">>, "..", trailing).
876+
2> string:split(<<"ab..bc..cd">>, "..", trailing).
877877
[<<"ab..bc">>,<<"cd">>]
878-
2> string:split(<<"ab..bc....cd">>, "..", all).
878+
3> string:split(<<"ab..bc....cd">>, "..", all).
879879
[<<"ab">>,<<"bc">>,<<>>,<<"cd">>]
880880
```
881881
""".
@@ -2531,13 +2531,6 @@ Returns the position where the first occurrence of `SubString` begins in
25312531
`String`. Returns `0` if `SubString` does not exist in `String`.
25322532

25332533
This function is [obsolete](`m:string#obsolete-api-functions`). Use `find/2`.
2534-
2535-
_Example:_
2536-
2537-
```erlang
2538-
1> string:str(" Hello Hello World World ", "Hello World").
2539-
8
2540-
```
25412534
""".
25422535
-doc(#{group => <<"Obsolete API functions">>}).
25432536
-spec str(String, SubString) -> Index when
@@ -2560,13 +2553,6 @@ Returns the position where the last occurrence of `SubString` begins in
25602553
`String`. Returns `0` if `SubString` does not exist in `String`.
25612554

25622555
This function is [obsolete](`m:string#obsolete-api-functions`). Use `find/3`.
2563-
2564-
_Example:_
2565-
2566-
```erlang
2567-
1> string:rstr(" Hello Hello World World ", "Hello World").
2568-
8
2569-
```
25702556
""".
25712557
-doc(#{group => <<"Obsolete API functions">>}).
25722558
-spec rstr(String, SubString) -> Index when
@@ -2596,13 +2582,6 @@ Returns the length of the maximum initial segment of `String`, which consists
25962582
entirely of characters from `Chars`.
25972583

25982584
This function is [obsolete](`m:string#obsolete-api-functions`). Use `take/2`.
2599-
2600-
_Example:_
2601-
2602-
```erlang
2603-
1> string:span("\t abcdef", " \t").
2604-
5
2605-
```
26062585
""".
26072586
-doc(#{group => <<"Obsolete API functions">>}).
26082587
-spec span(String, Chars) -> Length when
@@ -2624,13 +2603,6 @@ Returns the length of the maximum initial segment of `String`, which consists
26242603
entirely of characters not from `Chars`.
26252604

26262605
This function is [obsolete](`m:string#obsolete-api-functions`). Use `take/3`.
2627-
2628-
_Example:_
2629-
2630-
```erlang
2631-
1> string:cspan("\t abcdef", " \t").
2632-
0
2633-
```
26342606
""".
26352607
-doc(#{group => <<"Obsolete API functions">>}).
26362608
-spec cspan(String, Chars) -> Length when
@@ -2668,13 +2640,6 @@ Returns a substring of `String`, starting at position `Start`, and ending at the
26682640
end of the string or at length `Length`.
26692641

26702642
This function is [obsolete](`m:string#obsolete-api-functions`). Use `slice/3`.
2671-
2672-
_Example:_
2673-
2674-
```erlang
2675-
1> substr("Hello World", 4, 5).
2676-
"lo Wo"
2677-
```
26782643
""".
26792644
-doc(#{group => <<"Obsolete API functions">>}).
26802645
-spec substr(String, Start, Length) -> SubString when
@@ -2699,14 +2664,7 @@ substr2([_|String], S) -> substr2(String, S-1).
26992664
Returns a list of tokens in `String`, separated by the characters in
27002665
`SeparatorList`.
27012666

2702-
_Example:_
2703-
2704-
```erlang
2705-
1> tokens("abc defxxghix jkl", "x ").
2706-
["abc", "def", "ghi", "jkl"]
2707-
```
2708-
2709-
Notice that, as shown in this example, two or more adjacent separator characters
2667+
Notice that two or more adjacent separator characters
27102668
in `String` are treated as one. That is, there are no empty strings in the
27112669
resulting list of tokens.
27122670

@@ -2827,13 +2785,6 @@ words(String) -> words(String, $\s).
28272785
Returns the number of words in `String`, separated by blanks or `Character`.
28282786

28292787
This function is [obsolete](`m:string#obsolete-api-functions`). Use `lexemes/2`.
2830-
2831-
_Example:_
2832-
2833-
```erlang
2834-
1> words(" Hello old boy!", $o).
2835-
4
2836-
```
28372788
""".
28382789
-doc(#{group => <<"Obsolete API functions">>}).
28392790
-spec words(String, Character) -> Count when
@@ -2865,13 +2816,6 @@ or `Character`s.
28652816

28662817
This function is [obsolete](`m:string#obsolete-api-functions`). Use
28672818
`nth_lexeme/3`.
2868-
2869-
_Example:_
2870-
2871-
```erlang
2872-
1> string:sub_word(" Hello old boy !",3,$o).
2873-
"ld b"
2874-
```
28752819
""".
28762820
-doc(#{group => <<"Obsolete API functions">>}).
28772821
-spec sub_word(String, Number, Character) -> Word when
@@ -2925,13 +2869,6 @@ Returns a string, where leading or trailing, or both, blanks or a number of
29252869
[`strip/1`](`strip/1`) is equivalent to [`strip(String, both)`](`strip/2`).
29262870

29272871
This function is [obsolete](`m:string#obsolete-api-functions`). Use `trim/3`.
2928-
2929-
_Example:_
2930-
2931-
```erlang
2932-
1> string:strip("...Hello.....", both, $.).
2933-
"Hello"
2934-
```
29352872
""".
29362873
-doc(#{group => <<"Obsolete API functions">>}).
29372874
-spec strip(String, Direction, Character) -> Stripped when
@@ -2978,13 +2915,6 @@ padded with blanks or `Character`s.
29782915

29792916
This function is [obsolete](`m:string#obsolete-api-functions`). Use `pad/2` or
29802917
`pad/3`.
2981-
2982-
_Example:_
2983-
2984-
```erlang
2985-
1> string:left("Hello",10,$.).
2986-
"Hello....."
2987-
```
29882918
""".
29892919
-doc(#{group => <<"Obsolete API functions">>}).
29902920
-spec left(String, Number, Character) -> Left when
@@ -3020,13 +2950,6 @@ margin is fixed. If the length of `(String)` < `Number`, then `String` is padded
30202950
with blanks or `Character`s.
30212951

30222952
This function is [obsolete](`m:string#obsolete-api-functions`). Use `pad/3`.
3023-
3024-
_Example:_
3025-
3026-
```erlang
3027-
1> string:right("Hello", 10, $.).
3028-
".....Hello"
3029-
```
30302953
""".
30312954
-doc(#{group => <<"Obsolete API functions">>}).
30322955
-spec right(String, Number, Character) -> Right when
@@ -3097,13 +3020,6 @@ Returns a substring of `String`, starting at position `Start` to the end of the
30973020
string, or to and including position `Stop`.
30983021

30993022
This function is [obsolete](`m:string#obsolete-api-functions`). Use `slice/3`.
3100-
3101-
_Example:_
3102-
3103-
```erlang
3104-
1> sub_string("Hello World", 4, 8).
3105-
"lo Wo"
3106-
```
31073023
""".
31083024
-doc(#{group => <<"Obsolete API functions">>}).
31093025
-spec sub_string(String, Start, Stop) -> SubString when
@@ -3185,13 +3101,6 @@ Returns a string with the elements of `StringList` separated by the string in
31853101

31863102
This function is [obsolete](`m:string#obsolete-api-functions`). Use
31873103
`lists:join/2`.
3188-
3189-
_Example:_
3190-
3191-
```erlang
3192-
1> join(["one", "two", "three"], ", ").
3193-
"one, two, three"
3194-
```
31953104
""".
31963105
-doc(#{group => <<"Obsolete API functions">>}).
31973106
-spec join(StringList, Separator) -> String when

0 commit comments

Comments
 (0)