<commit_before>=begin pod

=head1  Str

    class Str is Cool does Stringy { }

Built-in class for strings. Objects of type C<Str> are immutable.

=head2 Methods

=head3  chop

    multi sub    chop(Str:D)  returns Str:D
    multi method chop(Str:D:) returns Str:D

Returns the string with one character removed from the end.

=head3  chomp

    multi sub    chomp(Str:D ) returns Str:D
    multi method chomp(Str:D:) returns Str:D

Returns the string with a newline removed from the end.

=head3 lc

    multi sub    lc(Str:D ) returns Str:D
    multi method lc(Str:D:) returns Str:D

Returns a lower-case version of the string.

=head3 uc

    multi sub    uc(Str:D ) returns Str:D
    multi method uc(Str:D:) returns Str:D

Returns an uppercase version of the string.

=head3 fc

    multi sub    fc(Str:D ) returns Str:D
    multi method fc(Str:D:) returns Str:D 

Does a Unicode "fold case" operation suitable for doing caseless
string comparisons.  (In general, the returned string is unlikely to
be useful for any purpose other than comparison.)

(Not implemented in Rakudo and Niecza)

=head3 titlecase

    multi sub    titlecase(Str:D  :&filter = &lc, :%exceptions = set()) returns Str
    multi method titlecase(Str:D: :&filter = &lc, :%exceptions = set()) returns Str

Performs a Unicode titlecase operation on the first character of
each word of the string (as defined by a regex C<«> boundary),
and forces the rest of the letters through a filter that defaults
to C<lc>.  After this operation, if any exceptions are supplied and
if the word is found in the set of exceptions, the first character is also
forced through the filter.  Note that the exceptions must be spelled with
an initial titlecase, such as "By" or "And", to produce "by" or "and".

Note, there is no longer any C<ucfirst> function because its semantics are not useful under Unicode.

(Not implemented in Rakudo and Niecza)

=head3 chars

    multi sub    chars(Str:D ) returns Int:D
    multi method chars(Str:D:) returns Int:D

Returns the number of characters in the string in the current
(lexically scoped) idea of what a normal character is, usually graphemes.

=head3 encode

    multi method encode(Str:D: $encoding = $?ENC, $nf = $?NF) returns Buf

Returns a C<Buf> which represents the original string in the given encoding
and normal form. The actual return type is as specific as possible, so
C<$str.encode('UTF-8')> returns a C<utf8> object,
C<$str.encode('ISO-8859-1')> a C<buf8>.

=head3 index

    multi sub    index(Str:D, Str:D $needle, Int $startpos = 0) returns Int
    multi method index(Str:D: Str:D $needle, Int $startpos = 0) returns Int

Searches for C<$needle> in the string starting from C<$startpos>. It returns
the offset into the string where C<$needle> was found, and an undefined value
if it was not found.


=end pod<commit_msg>Str.rindex<commit_after>=begin pod

=head1  Str

    class Str is Cool does Stringy { }

Built-in class for strings. Objects of type C<Str> are immutable.

=head2 Methods

=head3  chop

    multi sub    chop(Str:D)  returns Str:D
    multi method chop(Str:D:) returns Str:D

Returns the string with one character removed from the end.

=head3  chomp

    multi sub    chomp(Str:D ) returns Str:D
    multi method chomp(Str:D:) returns Str:D

Returns the string with a newline removed from the end.

=head3 lc

    multi sub    lc(Str:D ) returns Str:D
    multi method lc(Str:D:) returns Str:D

Returns a lower-case version of the string.

=head3 uc

    multi sub    uc(Str:D ) returns Str:D
    multi method uc(Str:D:) returns Str:D

Returns an uppercase version of the string.

=head3 fc

    multi sub    fc(Str:D ) returns Str:D
    multi method fc(Str:D:) returns Str:D 

Does a Unicode "fold case" operation suitable for doing caseless
string comparisons.  (In general, the returned string is unlikely to
be useful for any purpose other than comparison.)

(Not implemented in Rakudo and Niecza)

=head3 titlecase

    multi sub    titlecase(Str:D  :&filter = &lc, :%exceptions = set()) returns Str
    multi method titlecase(Str:D: :&filter = &lc, :%exceptions = set()) returns Str

Performs a Unicode titlecase operation on the first character of
each word of the string (as defined by a regex C<«> boundary),
and forces the rest of the letters through a filter that defaults
to C<lc>.  After this operation, if any exceptions are supplied and
if the word is found in the set of exceptions, the first character is also
forced through the filter.  Note that the exceptions must be spelled with
an initial titlecase, such as "By" or "And", to produce "by" or "and".

Note, there is no longer any C<ucfirst> function because its semantics are not useful under Unicode.

(Not implemented in Rakudo and Niecza)

=head3 chars

    multi sub    chars(Str:D ) returns Int:D
    multi method chars(Str:D:) returns Int:D

Returns the number of characters in the string in the current
(lexically scoped) idea of what a normal character is, usually graphemes.

=head3 encode

    multi method encode(Str:D: $encoding = $?ENC, $nf = $?NF) returns Buf

Returns a C<Buf> which represents the original string in the given encoding
and normal form. The actual return type is as specific as possible, so
C<$str.encode('UTF-8')> returns a C<utf8> object,
C<$str.encode('ISO-8859-1')> a C<buf8>.

=head3 index

    multi sub    index(Str:D, Str:D $needle, Int $startpos = 0) returns Int
    multi method index(Str:D: Str:D $needle, Int $startpos = 0) returns Int

Searches for C<$needle> in the string starting from C<$startpos>. It returns
the offset into the string where C<$needle> was found, and an undefined value
if it was not found.

=head3 rindex

    multi sub    rindex(Str:D $haystack, Str:D $needle, Int $startpos = $haystack.chars) returns Int
    multi method rindex(Str:D $haystack: Str:D $needle, Int $startpos = $haystack.chars) returns Int

Returns the last position of C<$needle> in C<$haystack> not after C<$startpos>.
Returns an undefined value if C<$needle> wasn't found.

=end pod
{'fraction_non_alphanumeric': 0.08073607427055703, 'fraction_numerical': 0.007128647214854111, 'mean_word_length': 3.873182552504039, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1715676', 'n_tokens_mistral': 1918, 'n_tokens_neox': 1835, 'n_words': 860}