@@ -691,17 +691,20 @@ Example:
691
691
multi method trans(Str:D: Pair:D \what, *%n) returns Str
692
692
multi method trans(Str:D: *@changes, :complement(:$c), :squash(:$s), :delete(:$d)) returns Str
693
693
694
- Replaces one or many substrings with one or many strings. Ranges are supported, both for keys and
695
- values. Regexes work as keys. When called with C < :complement > anything but the matched value or range
696
- is replaced with a single value. With C < :delete > the matched characters are removed.
697
- Combining C < :complement > and C < :delete > will remove anything but the matched values.
698
- The adverb C < :squash > will reduce repeated matched characters to a single character.
694
+ Replaces one or many characters with one or many characters. Ranges are
695
+ supported, both for keys and values. Regexes work as keys. In case a list of
696
+ keys and values is used, substrings can be replaced aswell. When called with
697
+ C < :complement > anything but the matched value or range is replaced with a
698
+ single value. With C < :delete > the matched characters are removed. Combining
699
+ C < :complement > and C < :delete > will remove anything but the matched values. The
700
+ adverb C < :squash > will reduce repeated matched characters to a single
701
+ character.
699
702
700
703
Example:
701
704
702
705
my $str = 'say $x<b> && $y<a>';
703
- $str.=trans( '<' => '< ' );
704
- $str.=trans( '<' => '< ', '>' => '> ' );
706
+ $str.=trans( '<' => '« ' );
707
+ $str.=trans( '<' => '« ', '>' => '» ' );
705
708
706
709
$str.=trans( [ '<' , '>' , '&' ] =>
707
710
[ '<', '>', '&' ]);
0 commit comments