Skip to content

Commit

Permalink
Document :st, :nd, :rd, and :th adverbs on .subst
Browse files Browse the repository at this point in the history
  • Loading branch information
zoffixznet committed Sep 27, 2016
1 parent a6d207f commit ac4b28c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion doc/Type/Str.pod6
Expand Up @@ -691,14 +691,21 @@ 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 C<:nth> adverb has readable English-looking variants:
say 'ooooo'.subst: 'o', 'x', :1st; xoooo
say 'ooooo'.subst: 'o', 'x', :2nd; oxooo
say 'ooooo'.subst: 'o', 'x', :3rd; ooxoo
say 'ooooo'.subst: 'o', 'x', :4th; oooxo
The following adverbs are supported
=begin table
short long meaning
===== ==== =======
:g :global tries to match as often as possible
:nth(Int|Callable) only substitute the nth's match
:nth(Int|Callable) only substitute the nth's match; aliases: :st, :nd, :rd, and :th
:ss :samespace preserves whitespace on substitution
:ii :samecase preserves case on substitution
:mm :samemark preserves character marks (e.g. 'ü' replaced with 'o' will result in 'ö')
Expand Down

0 comments on commit ac4b28c

Please sign in to comment.