Skip to content

Commit ac4b28c

Browse files
authored
Document :st, :nd, :rd, and :th adverbs on .subst
1 parent a6d207f commit ac4b28c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

doc/Type/Str.pod6

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,14 +691,21 @@ Here are other examples of usage:
691691
692692
$str.subst(/foo/, "bar", :nth(3)); # replace nth match alone. Replaces the third foo. Returns Hey foo foo bar
693693
694+
The C<:nth> adverb has readable English-looking variants:
695+
696+
say 'ooooo'.subst: 'o', 'x', :1st; xoooo
697+
say 'ooooo'.subst: 'o', 'x', :2nd; oxooo
698+
say 'ooooo'.subst: 'o', 'x', :3rd; ooxoo
699+
say 'ooooo'.subst: 'o', 'x', :4th; oooxo
700+
694701
The following adverbs are supported
695702
696703
=begin table
697704
698705
short long meaning
699706
===== ==== =======
700707
:g :global tries to match as often as possible
701-
:nth(Int|Callable) only substitute the nth's match
708+
:nth(Int|Callable) only substitute the nth's match; aliases: :st, :nd, :rd, and :th
702709
:ss :samespace preserves whitespace on substitution
703710
:ii :samecase preserves case on substitution
704711
:mm :samemark preserves character marks (e.g. 'ü' replaced with 'o' will result in 'ö')

0 commit comments

Comments
 (0)