Permalink
Browse files

[Str] implement adverbs for .subst

  • Loading branch information...
moritz committed Dec 25, 2012
1 parent 4f6552b commit 4b715a979de01655489e6fb154f1b5563a1aa198
Showing with 19 additions and 0 deletions.
  1. +19 −0 lib/Str.pod
View
@@ -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

0 comments on commit 4b715a9

Please sign in to comment.