1string(3)                  Erlang Module Definition                  string(3)
2
3
4

NAME

6       string - String processing functions.
7

DESCRIPTION

9       This module provides functions for string processing.
10
11       A  string in this module is represented by unicode:chardata(), that is,
12       a list of codepoints, binaries with UTF-8-encoded codepoints (UTF-8 bi‐
13       naries), or a mix of the two.
14
15       "abcd"               is a valid string
16       <<"abcd">>           is a valid string
17       ["abcd"]             is a valid string
18       <<"abc..åäö"/utf8>>  is a valid string
19       <<"abc..åäö">>       is NOT a valid string,
20                            but a binary with Latin-1-encoded codepoints
21       [<<"abc">>, "..åäö"] is a valid string
22       [atom]               is NOT a valid string
23
24       This  module  operates  on  grapheme  clusters. A grapheme cluster is a
25       user-perceived character, which can be  represented  by  several  code‐
26       points.
27
28       "å"  [229] or [97, 778]
29       "e̊"  [101, 778]
30
31       The  string length of "ß↑e̊" is 3, even though it is represented by the
32       codepoints     [223,8593,101,778]     or     the      UTF-8      binary
33       <<195,159,226,134,145,101,204,138>>.
34
35       Grapheme  clusters  for  codepoints of class prepend and non-modern (or
36       decomposed) Hangul is not handled for performance  reasons  in  find/3,
37       replace/3, split/2, split/2 and trim/3.
38
39       Splitting and appending strings is to be done on grapheme clusters bor‐
40       ders. There is no verification that the results  of  appending  strings
41       are valid or normalized.
42
43       Most  of  the  functions expect all input to be normalized to one form,
44       see for example unicode:characters_to_nfc_list/1.
45
46       Language or locale specific handling of input is not considered in  any
47       function.
48
49       The  functions  can crash for non-valid input strings. For example, the
50       functions expect UTF-8 binaries but not all functions verify  that  all
51       binaries are encoded correctly.
52
53       Unless otherwise specified the return value type is the same as the in‐
54       put type. That is, binary input returns binary output, list  input  re‐
55       turns a list output, and mixed input can return a mixed output.
56
57       1> string:trim("  sarah  ").
58       "sarah"
59       2> string:trim(<<"  sarah  ">>).
60       <<"sarah">>
61       3> string:lexemes("foo bar", " ").
62       ["foo","bar"]
63       4> string:lexemes(<<"foo bar">>, " ").
64       [<<"foo">>,<<"bar">>]
65
66       This  module has been reworked in Erlang/OTP 20 to handle unicode:char‐
67       data() and operate on grapheme clusters. The old  functions  that  only
68       work  on  Latin-1  lists as input are still available but should not be
69       used, they will be deprecated in a future release.
70

DATA TYPES

72       direction() = leading | trailing
73
74       grapheme_cluster() = char() | [char()]
75
76              A user-perceived character, consisting  of  one  or  more  code‐
77              points.
78

EXPORTS

80       casefold(String :: unicode:chardata()) -> unicode:chardata()
81
82              Converts  String  to a case-agnostic comparable string. Function
83              casefold/1 is preferred over lowercase/1 when two strings are to
84              be compared for equality. See also equal/4.
85
86              Example:
87
88              1> string:casefold("Ω and ẞ SHARP S").
89              "ω and ss sharp s"
90
91       chomp(String :: unicode:chardata()) -> unicode:chardata()
92
93              Returns a string where any trailing \n or \r\n have been removed
94              from String.
95
96              Example:
97
98              182> string:chomp(<<"\nHello\n\n">>).
99              <<"\nHello">>
100              183> string:chomp("\nHello\r\r\n").
101              "\nHello\r"
102
103       equal(A, B) -> boolean()
104
105       equal(A, B, IgnoreCase) -> boolean()
106
107       equal(A, B, IgnoreCase, Norm) -> boolean()
108
109              Types:
110
111                 A = B = unicode:chardata()
112                 IgnoreCase = boolean()
113                 Norm = none | nfc | nfd | nfkc | nfkd
114
115              Returns true if A and B are equal, otherwise false.
116
117              If IgnoreCase is true the function does casefolding on  the  fly
118              before the equality test.
119
120              If  Norm  is  not none the function applies normalization on the
121              fly before the equality test. There are four  available  normal‐
122              ization forms: nfc, nfd, nfkc, and nfkd.
123
124              By default, IgnoreCase is false and Norm is none.
125
126              Example:
127
128              1> string:equal("åäö", <<"åäö"/utf8>>).
129              true
130              2> string:equal("åäö", unicode:characters_to_nfd_binary("åäö")).
131              false
132              3> string:equal("åäö", unicode:characters_to_nfd_binary("ÅÄÖ"), true, nfc).
133              true
134
135       find(String, SearchPattern) -> unicode:chardata() | nomatch
136
137       find(String, SearchPattern, Dir) -> unicode:chardata() | nomatch
138
139              Types:
140
141                 String = SearchPattern = unicode:chardata()
142                 Dir = direction()
143
144              Removes  anything before SearchPattern in String and returns the
145              remainder of the string  or  nomatch  if  SearchPattern  is  not
146              found.  Dir,  which  can  be leading or trailing, indicates from
147              which direction characters are to be searched.
148
149              By default, Dir is leading.
150
151              Example:
152
153              1> string:find("ab..cd..ef", ".").
154              "..cd..ef"
155              2> string:find(<<"ab..cd..ef">>, "..", trailing).
156              <<"..ef">>
157              3> string:find(<<"ab..cd..ef">>, "x", leading).
158              nomatch
159              4> string:find("ab..cd..ef", "x", trailing).
160              nomatch
161
162       is_empty(String :: unicode:chardata()) -> boolean()
163
164              Returns true if String is the empty string, otherwise false.
165
166              Example:
167
168              1> string:is_empty("foo").
169              false
170              2> string:is_empty(["",<<>>]).
171              true
172
173       length(String :: unicode:chardata()) -> integer() >= 0
174
175              Returns the number of grapheme clusters in String.
176
177              Example:
178
179              1> string:length("ß↑e̊").
180              3
181              2> string:length(<<195,159,226,134,145,101,204,138>>).
182              3
183
184       lexemes(String :: unicode:chardata(),
185               SeparatorList :: [grapheme_cluster()]) ->
186                  [unicode:chardata()]
187
188              Returns a list of lexemes in String, separated by  the  grapheme
189              clusters in SeparatorList.
190
191              Notice that, as shown in this example, two or more adjacent sep‐
192              arator graphemes clusters in String are treated as one. That is,
193              there are no empty strings in the resulting list of lexemes. See
194              also split/3 which returns empty strings.
195
196              Notice that [$\r,$\n] is one grapheme cluster.
197
198              Example:
199
200              1> string:lexemes("abc de̊fxxghix jkl\r\nfoo", "x e" ++ [[$\r,$\n]]).
201              ["abc","de̊f","ghi","jkl","foo"]
202              2> string:lexemes(<<"abc de̊fxxghix jkl\r\nfoo"/utf8>>, "x e" ++ [$\r,$\n]).
203              [<<"abc">>,<<"de̊f"/utf8>>,<<"ghi">>,<<"jkl\r\nfoo">>]
204
205       lowercase(String :: unicode:chardata()) -> unicode:chardata()
206
207              Converts String to lowercase.
208
209              Notice that function casefold/1 should be used when converting a
210              string to be tested for equality.
211
212              Example:
213
214              2> string:lowercase(string:uppercase("Michał")).
215              "michał"
216
217       next_codepoint(String :: unicode:chardata()) ->
218                         maybe_improper_list(char(), unicode:chardata()) |
219                         {error, unicode:chardata()}
220
221              Returns  the first codepoint in String and the rest of String in
222              the tail. Returns an empty list if String is empty or an {error,
223              String} tuple if the next byte is invalid.
224
225              Example:
226
227              1> string:next_codepoint(unicode:characters_to_binary("e̊fg")).
228              [101|<<"̊fg"/utf8>>]
229
230       next_grapheme(String :: unicode:chardata()) ->
231                        maybe_improper_list(grapheme_cluster(),
232                                            unicode:chardata()) |
233                        {error, unicode:chardata()}
234
235              Returns  the  first  grapheme  cluster in String and the rest of
236              String in the tail. Returns an empty list if String is empty  or
237              an {error, String} tuple if the next byte is invalid.
238
239              Example:
240
241              1> string:next_grapheme(unicode:characters_to_binary("e̊fg")).
242              ["e̊"|<<"fg">>]
243
244       nth_lexeme(String, N, SeparatorList) -> unicode:chardata()
245
246              Types:
247
248                 String = unicode:chardata()
249                 N = integer() >= 0
250                 SeparatorList = [grapheme_cluster()]
251
252              Returns  lexeme  number N in String, where lexemes are separated
253              by the grapheme clusters in SeparatorList.
254
255              Example:
256
257              1> string:nth_lexeme("abc.de̊f.ghiejkl", 3, ".e").
258              "ghi"
259
260       pad(String, Length) -> unicode:charlist()
261
262       pad(String, Length, Dir) -> unicode:charlist()
263
264       pad(String, Length, Dir, Char) -> unicode:charlist()
265
266              Types:
267
268                 String = unicode:chardata()
269                 Length = integer()
270                 Dir = direction() | both
271                 Char = grapheme_cluster()
272
273              Pads String to Length with grapheme cluster Char. Dir, which can
274              be  leading,  trailing,  or  both,  indicates  where the padding
275              should be added.
276
277              By default, Char is $\s and Dir is trailing.
278
279              Example:
280
281              1> string:pad(<<"He̊llö"/utf8>>, 8).
282              [<<72,101,204,138,108,108,195,182>>,32,32,32]
283              2> io:format("'~ts'~n",[string:pad("He̊llö", 8, leading)]).
284              3> io:format("'~ts'~n",[string:pad("He̊llö", 8, both)]).
285
286       prefix(String :: unicode:chardata(), Prefix :: unicode:chardata()) ->
287                 nomatch | unicode:chardata()
288
289              If Prefix is the prefix of String, removes it  and  returns  the
290              remainder of String, otherwise returns nomatch.
291
292              Example:
293
294              1> string:prefix(<<"prefix of string">>, "pre").
295              <<"fix of string">>
296              2> string:prefix("pre", "prefix").
297              nomatch
298
299       replace(String, SearchPattern, Replacement) ->
300                  [unicode:chardata()]
301
302       replace(String, SearchPattern, Replacement, Where) ->
303                  [unicode:chardata()]
304
305              Types:
306
307                 String = SearchPattern = Replacement = unicode:chardata()
308                 Where = direction() | all
309
310              Replaces  SearchPattern  in  String with Replacement. Where, de‐
311              fault leading, indicates whether the leading,  the  trailing  or
312              all encounters of SearchPattern are to be replaced.
313
314              Can be implemented as:
315
316              lists:join(Replacement, split(String, SearchPattern, Where)).
317
318              Example:
319
320              1> string:replace(<<"ab..cd..ef">>, "..", "*").
321              [<<"ab">>,"*",<<"cd..ef">>]
322              2> string:replace(<<"ab..cd..ef">>, "..", "*", all).
323              [<<"ab">>,"*",<<"cd">>,"*",<<"ef">>]
324
325       reverse(String :: unicode:chardata()) -> [grapheme_cluster()]
326
327              Returns the reverse list of the grapheme clusters in String.
328
329              Example:
330
331              1> Reverse = string:reverse(unicode:characters_to_nfd_binary("ÅÄÖ")).
332              [[79,776],[65,776],[65,778]]
333              2> io:format("~ts~n",[Reverse]).
334              ÖÄÅ
335
336       slice(String, Start) -> Slice
337
338       slice(String, Start, Length) -> Slice
339
340              Types:
341
342                 String = unicode:chardata()
343                 Start = integer() >= 0
344                 Length = infinity | integer() >= 0
345                 Slice = unicode:chardata()
346
347              Returns  a  substring of String of at most Length grapheme clus‐
348              ters, starting at position Start.
349
350              By default, Length is infinity.
351
352              Example:
353
354              1> string:slice(<<"He̊llö Wörld"/utf8>>, 4).
355              <<"ö Wörld"/utf8>>
356              2> string:slice(["He̊llö ", <<"Wörld"/utf8>>], 4,4).
357              "ö Wö"
358              3> string:slice(["He̊llö ", <<"Wörld"/utf8>>], 4,50).
359              "ö Wörld"
360
361       split(String, SearchPattern) -> [unicode:chardata()]
362
363       split(String, SearchPattern, Where) -> [unicode:chardata()]
364
365              Types:
366
367                 String = SearchPattern = unicode:chardata()
368                 Where = direction() | all
369
370              Splits String where SearchPattern is encountered and return  the
371              remaining  parts.  Where, default leading, indicates whether the
372              leading, the trailing or all encounters  of  SearchPattern  will
373              split String.
374
375              Example:
376
377              0> string:split("ab..bc..cd", "..").
378              ["ab","bc..cd"]
379              1> string:split(<<"ab..bc..cd">>, "..", trailing).
380              [<<"ab..bc">>,<<"cd">>]
381              2> string:split(<<"ab..bc....cd">>, "..", all).
382              [<<"ab">>,<<"bc">>,<<>>,<<"cd">>]
383
384       take(String, Characters) -> {Leading, Trailing}
385
386       take(String, Characters, Complement) -> {Leading, Trailing}
387
388       take(String, Characters, Complement, Dir) -> {Leading, Trailing}
389
390              Types:
391
392                 String = unicode:chardata()
393                 Characters = [grapheme_cluster()]
394                 Complement = boolean()
395                 Dir = direction()
396                 Leading = Trailing = unicode:chardata()
397
398              Takes  characters from String as long as the characters are mem‐
399              bers of set Characters or the complement of set Characters. Dir,
400              which can be leading or trailing, indicates from which direction
401              characters are to be taken.
402
403              Example:
404
405              5> string:take("abc0z123", lists:seq($a,$z)).
406              {"abc","0z123"}
407              6> string:take(<<"abc0z123">>, lists:seq($0,$9), true, leading).
408              {<<"abc">>,<<"0z123">>}
409              7> string:take("abc0z123", lists:seq($0,$9), false, trailing).
410              {"abc0z","123"}
411              8> string:take(<<"abc0z123">>, lists:seq($a,$z), true, trailing).
412              {<<"abc0z">>,<<"123">>}
413
414       titlecase(String :: unicode:chardata()) -> unicode:chardata()
415
416              Converts String to titlecase.
417
418              Example:
419
420              1> string:titlecase("ß is a SHARP s").
421              "Ss is a SHARP s"
422
423       to_float(String) -> {Float, Rest} | {error, Reason}
424
425              Types:
426
427                 String = unicode:chardata()
428                 Float = float()
429                 Rest = unicode:chardata()
430                 Reason = no_float | badarg
431
432              Argument String is expected to start with a  valid  text  repre‐
433              sented float (the digits are ASCII values). Remaining characters
434              in the string after the float are returned in Rest.
435
436              Example:
437
438              > {F1,Fs} = string:to_float("1.0-1.0e-1"),
439              > {F2,[]} = string:to_float(Fs),
440              > F1+F2.
441              0.9
442              > string:to_float("3/2=1.5").
443              {error,no_float}
444              > string:to_float("-1.5eX").
445              {-1.5,"eX"}
446
447       to_integer(String) -> {Int, Rest} | {error, Reason}
448
449              Types:
450
451                 String = unicode:chardata()
452                 Int = integer()
453                 Rest = unicode:chardata()
454                 Reason = no_integer | badarg
455
456              Argument String is expected to start with a  valid  text  repre‐
457              sented  integer (the digits are ASCII values). Remaining charac‐
458              ters in the string after the integer are returned in Rest.
459
460              Example:
461
462              > {I1,Is} = string:to_integer("33+22"),
463              > {I2,[]} = string:to_integer(Is),
464              > I1-I2.
465              11
466              > string:to_integer("0.5").
467              {0,".5"}
468              > string:to_integer("x=2").
469              {error,no_integer}
470
471       to_graphemes(String :: unicode:chardata()) -> [grapheme_cluster()]
472
473              Converts String to a list of grapheme clusters.
474
475              Example:
476
477              1> string:to_graphemes("ß↑e̊").
478              [223,8593,[101,778]]
479              2> string:to_graphemes(<<"ß↑e̊"/utf8>>).
480              [223,8593,[101,778]]
481
482       trim(String) -> unicode:chardata()
483
484       trim(String, Dir) -> unicode:chardata()
485
486       trim(String, Dir, Characters) -> unicode:chardata()
487
488              Types:
489
490                 String = unicode:chardata()
491                 Dir = direction() | both
492                 Characters = [grapheme_cluster()]
493
494              Returns a string, where leading or trailing, or both, Characters
495              have  been removed. Dir which can be leading, trailing, or both,
496              indicates from which direction characters are to be removed.
497
498              Default Characters is the set of nonbreakable  whitespace  code‐
499              points, defined as Pattern_White_Space in Unicode Standard Annex
500              #31. By default, Dir is both.
501
502              Notice that [$\r,$\n] is one grapheme cluster according  to  the
503              Unicode Standard.
504
505              Example:
506
507              1> string:trim("\t Hello \n").
508              "Hello"
509              2> string:trim(<<"\t Hello \n">>, leading).
510              <<"Hello  \n">>
511              3> string:trim(<<".Hello.\n">>, trailing, "\n.").
512              <<".Hello">>
513
514       uppercase(String :: unicode:chardata()) -> unicode:chardata()
515
516              Converts String to uppercase.
517
518              See also titlecase/1.
519
520              Example:
521
522              1> string:uppercase("Michał").
523              "MICHAŁ"
524

OBSOLETE API FUNCTIONS

526       Here  follows the function of the old API. These functions only work on
527       a list of Latin-1 characters.
528
529   Note:
530       The functions are kept for backward compatibility, but are  not  recom‐
531       mended. They will be deprecated in a future release.
532
533       Any undocumented functions in string are not to be used.
534
535

EXPORTS

537       centre(String, Number) -> Centered
538
539       centre(String, Number, Character) -> Centered
540
541              Types:
542
543                 String = Centered = string()
544                 Number = integer() >= 0
545                 Character = char()
546
547              Returns  a  string,  where  String is centered in the string and
548              surrounded by blanks or  Character.  The  resulting  string  has
549              length Number.
550
551              This function is obsolete. Use pad/3.
552
553       chars(Character, Number) -> String
554
555       chars(Character, Number, Tail) -> String
556
557              Types:
558
559                 Character = char()
560                 Number = integer() >= 0
561                 Tail = String = string()
562
563              Returns  a string consisting of Number characters Character. Op‐
564              tionally, the string can end with string Tail.
565
566              This function is obsolete. Use lists:duplicate/2.
567
568       chr(String, Character) -> Index
569
570              Types:
571
572                 String = string()
573                 Character = char()
574                 Index = integer() >= 0
575
576              Returns the index  of  the  first  occurrence  of  Character  in
577              String. Returns 0 if Character does not occur.
578
579              This function is obsolete. Use find/2.
580
581       concat(String1, String2) -> String3
582
583              Types:
584
585                 String1 = String2 = String3 = string()
586
587              Concatenates  String1  and String2 to form a new string String3,
588              which is returned.
589
590              This function is obsolete. Use [String1, String2] as Data  argu‐
591              ment,  and  call unicode:characters_to_list/2 or unicode:charac‐
592              ters_to_binary/2 to flatten the output.
593
594       copies(String, Number) -> Copies
595
596              Types:
597
598                 String = Copies = string()
599                 Number = integer() >= 0
600
601              Returns a string containing String repeated Number times.
602
603              This function is obsolete. Use lists:duplicate/2.
604
605       cspan(String, Chars) -> Length
606
607              Types:
608
609                 String = Chars = string()
610                 Length = integer() >= 0
611
612              Returns the length of the maximum  initial  segment  of  String,
613              which consists entirely of characters not from Chars.
614
615              This function is obsolete. Use take/3.
616
617              Example:
618
619              > string:cspan("\t    abcdef", " \t").
620              0
621
622       join(StringList, Separator) -> String
623
624              Types:
625
626                 StringList = [string()]
627                 Separator = String = string()
628
629              Returns  a  string  with the elements of StringList separated by
630              the string in Separator.
631
632              This function is obsolete. Use lists:join/2.
633
634              Example:
635
636              > join(["one", "two", "three"], ", ").
637              "one, two, three"
638
639       left(String, Number) -> Left
640
641       left(String, Number, Character) -> Left
642
643              Types:
644
645                 String = Left = string()
646                 Number = integer() >= 0
647                 Character = char()
648
649              Returns String with the length adjusted in accordance with  Num‐
650              ber.  The left margin is fixed. If length(String) < Number, then
651              String is padded with blanks or Characters.
652
653              This function is obsolete. Use pad/2 or pad/3.
654
655              Example:
656
657              > string:left("Hello",10,$.).
658              "Hello....."
659
660       len(String) -> Length
661
662              Types:
663
664                 String = string()
665                 Length = integer() >= 0
666
667              Returns the number of characters in String.
668
669              This function is obsolete. Use length/1.
670
671       rchr(String, Character) -> Index
672
673              Types:
674
675                 String = string()
676                 Character = char()
677                 Index = integer() >= 0
678
679              Returns the index of the last occurrence of Character in String.
680              Returns 0 if Character does not occur.
681
682              This function is obsolete. Use find/3.
683
684       right(String, Number) -> Right
685
686       right(String, Number, Character) -> Right
687
688              Types:
689
690                 String = Right = string()
691                 Number = integer() >= 0
692                 Character = char()
693
694              Returns  String with the length adjusted in accordance with Num‐
695              ber. The right margin is fixed. If the length of (String) < Num‐
696              ber, then String is padded with blanks or Characters.
697
698              This function is obsolete. Use pad/3.
699
700              Example:
701
702              > string:right("Hello", 10, $.).
703              ".....Hello"
704
705       rstr(String, SubString) -> Index
706
707              Types:
708
709                 String = SubString = string()
710                 Index = integer() >= 0
711
712              Returns  the position where the last occurrence of SubString be‐
713              gins in String. Returns 0 if SubString does not exist in String.
714
715              This function is obsolete. Use find/3.
716
717              Example:
718
719              > string:rstr(" Hello Hello World World ", "Hello World").
720              8
721
722       span(String, Chars) -> Length
723
724              Types:
725
726                 String = Chars = string()
727                 Length = integer() >= 0
728
729              Returns the length of the maximum  initial  segment  of  String,
730              which consists entirely of characters from Chars.
731
732              This function is obsolete. Use take/2.
733
734              Example:
735
736              > string:span("\t    abcdef", " \t").
737              5
738
739       str(String, SubString) -> Index
740
741              Types:
742
743                 String = SubString = string()
744                 Index = integer() >= 0
745
746              Returns the position where the first occurrence of SubString be‐
747              gins in String. Returns 0 if SubString does not exist in String.
748
749              This function is obsolete. Use find/2.
750
751              Example:
752
753              > string:str(" Hello Hello World World ", "Hello World").
754              8
755
756       strip(String :: string()) -> string()
757
758       strip(String, Direction) -> Stripped
759
760       strip(String, Direction, Character) -> Stripped
761
762              Types:
763
764                 String = Stripped = string()
765                 Direction = left | right | both
766                 Character = char()
767
768              Returns a string, where leading or trailing, or both, blanks  or
769              a number of Character have been removed. Direction, which can be
770              left, right, or both, indicates from which direction blanks  are
771              to be removed. strip/1 is equivalent to strip(String, both).
772
773              This function is obsolete. Use trim/3.
774
775              Example:
776
777              > string:strip("...Hello.....", both, $.).
778              "Hello"
779
780       sub_string(String, Start) -> SubString
781
782       sub_string(String, Start, Stop) -> SubString
783
784              Types:
785
786                 String = SubString = string()
787                 Start = Stop = integer() >= 1
788
789              Returns a substring of String, starting at position Start to the
790              end of the string, or to and including position Stop.
791
792              This function is obsolete. Use slice/3.
793
794              Example:
795
796              sub_string("Hello World", 4, 8).
797              "lo Wo"
798
799       substr(String, Start) -> SubString
800
801       substr(String, Start, Length) -> SubString
802
803              Types:
804
805                 String = SubString = string()
806                 Start = integer() >= 1
807                 Length = integer() >= 0
808
809              Returns a substring of String, starting at position  Start,  and
810              ending at the end of the string or at length Length.
811
812              This function is obsolete. Use slice/3.
813
814              Example:
815
816              > substr("Hello World", 4, 5).
817              "lo Wo"
818
819       sub_word(String, Number) -> Word
820
821       sub_word(String, Number, Character) -> Word
822
823              Types:
824
825                 String = Word = string()
826                 Number = integer()
827                 Character = char()
828
829              Returns  the  word in position Number of String. Words are sepa‐
830              rated by blanks or Characters.
831
832              This function is obsolete. Use nth_lexeme/3.
833
834              Example:
835
836              > string:sub_word(" Hello old boy !",3,$o).
837              "ld b"
838
839       to_lower(String) -> Result
840
841       to_lower(Char) -> CharResult
842
843       to_upper(String) -> Result
844
845       to_upper(Char) -> CharResult
846
847              Types:
848
849                 String = Result = io_lib:latin1_string()
850                 Char = CharResult = char()
851
852              The specified string or character is case-converted. Notice that
853              the supported character set is ISO/IEC 8859-1 (also called Latin
854              1); all values outside this set are unchanged
855
856              This function is obsolete use lowercase/1,  uppercase/1,  title‐
857              case/1 or casefold/1.
858
859       tokens(String, SeparatorList) -> Tokens
860
861              Types:
862
863                 String = SeparatorList = string()
864                 Tokens = [Token :: nonempty_string()]
865
866              Returns  a list of tokens in String, separated by the characters
867              in SeparatorList.
868
869              Example:
870
871              > tokens("abc defxxghix jkl", "x ").
872              ["abc", "def", "ghi", "jkl"]
873
874              Notice that, as shown in this example, two or more adjacent sep‐
875              arator  characters  in String are treated as one. That is, there
876              are no empty strings in the resulting list of tokens.
877
878              This function is obsolete. Use lexemes/2.
879
880       words(String) -> Count
881
882       words(String, Character) -> Count
883
884              Types:
885
886                 String = string()
887                 Character = char()
888                 Count = integer() >= 1
889
890              Returns the number of words in String, separated  by  blanks  or
891              Character.
892
893              This function is obsolete. Use lexemes/2.
894
895              Example:
896
897              > words(" Hello old boy!", $o).
898              4
899

NOTES

901       Some  of  the  general string functions can seem to overlap each other.
902       The reason is that this string package is the combination of  two  ear‐
903       lier packages and all functions of both packages have been retained.
904
905
906
907Ericsson AB                     stdlib 3.14.2.1                      string(3)
Impressum