in reply to substitution in regular expression
All this to introduce the fact that I will propose a rather concise solution with an explicit loop in the following Perl one-liner:
I did not check, but it is likely to be faster that any regex on large data input. Check it and tell your teacher about your findings on the various solutions, you might get an A+.$ perl -le 'my $s = "ABCDEF"; print substr $s, $_, 3 for 0..length($s) +-3;' ABC BCD CDE DEF
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: substitution in regular expression
by aeqr (Novice) on Apr 23, 2014 at 21:54 UTC |