File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -691,14 +691,21 @@ Here are other examples of usage:
691
691
692
692
$str.subst(/foo/, "bar", :nth(3)); # replace nth match alone. Replaces the third foo. Returns Hey foo foo bar
693
693
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
+
694
701
The following adverbs are supported
695
702
696
703
= begin table
697
704
698
705
short long meaning
699
706
===== ==== =======
700
707
: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
702
709
:ss :samespace preserves whitespace on substitution
703
710
:ii :samecase preserves case on substitution
704
711
:mm :samemark preserves character marks (e.g. 'ü' replaced with 'o' will result in 'ö')
You can’t perform that action at this time.
0 commit comments