parrotcode: C<Str>-like functions and methods for C<Any> | |
Contents | Language Implementations | Perl6 |
src/builtins/any-str.pir - Str
-like functions and methods for Any
This file implements the methods and functions of Any
that are most closely associated with the Str
class or role.
We place them here instead of src/classes/Any.pir to keep the size of that file down and to emphasize their generic,
"built-in" nature.
our Str multi Str::capitalize ( Str $string )
lc
on the entire string, then performing a s:g/(\w+)/{ucfirst $1}/
on it. our Str method Str::chop ( Str $string: )
our Str method Str::chomp ( Str $string: )
Returns string with newline removed from the end. An arbitrary
terminator can be removed if the input filehandle has marked the
string for where the "newline" begins. (Presumably this is stored
as a property of the string.) Otherwise a standard newline is removed.
our Bool multi Str::':e' ( Str $filename )
our Str multi Str::lc ( Str $string )
our Str multi Str::lcfirst ( Str $string )
lc
, but only affects the first character. our List multi Str::split ( Str $delimiter , Str $input = $+_, Int $limit = inf )
our List multi Str::split ( Rule $delimiter = /\s+/, Str $input = $+_, Int $limit = inf )
our List multi Str::split ( Str $input : Str $delimiter , Int $limit = inf )
our List multi Str::split ( Str $input : Rule $delimiter , Int $limit = inf )
split(' ')
will translate to .words
or some such. Null trailing fields are no longer trimmed by default. We might add some kind of :trim flag or introduce a trimlist function of some sort. Implementation of transliteration
our Str method Str::subst ( Any $string: Any $substring, Any $replacement )
our Str method Str::subst ( Any $string: Code $regexp, Any $replacement )
our Str multi Str::uc ( Str $string )
our Str multi Str::ucfirst ( Str $string )
|