Thread String, character, suche und ersetzen
(26 answers)
Opened by Graf Herschel at 2018-12-11 10:42
Da tuts doch eigentlich eine Stinknormale Schleife von Length(string) runter bis 0
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 my $min_idx = 5; # EDIT: Den $min_idx eingebaut my $string = "abcdefABCDEF"; for (my $i = length($string)-1; $i >= $min_idx; $i--) { if (substr($string, $i, 1) ~~ ['C', 'B', 'f']) { substr($string, $i, 1) = 'K'; last; } } say $string; Last edited: 2018-12-11 16:40:05 +0100 (CET) 1 + 1 = 10
|