Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Str] implement adverbs for .subst
  • Loading branch information
moritz committed Dec 25, 2012
1 parent 4f6552b commit 4b715a9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/Str.pod
Expand Up @@ -364,6 +364,25 @@ Here are other examples of usage:
$str.subst(/foo/, "bar", :nth(3)); # replace nth match alone. Replaces the third foo. Returns Hey foo foo bar
The following adverbs are supported
=begin table
short long meaning
===== ==== =======
:g :global tries to match as often as possible
:nth(Int) only substitute the nth's match
:ss :samespace preserves whitespace on subsitution
:ii :samecase preserives case on substitution
:x(Int) substitute exactly $x matches
=end table
Note that only in the C<s///> form C<:ii> implies C<:i> and C<:ss> implies
C<:s>. In the method form, the C<:s> and C<:i> modifiers must be added to the
regex, not the C<subst> method call.
=head2 substr
multi sub substr(Str:D $s, Int:D $from, Int:D $chars = $s.chars - $from) returns Str:D
Expand Down

0 comments on commit 4b715a9

Please sign in to comment.