in reply to How to split a string based on the length of a sequence of characters within the string
See the documentation of split: if you include a capture group in the regular expression, split will include the separator in its output.
$ perl -wMstrict -le 'print join ",", split /[a-z]/, "1a2b3c4"' 1,2,3,4 $ perl -wMstrict -le 'print join ",", split /([a-z])/, "1a2b3c4"' 1,a,2,b,3,c,4
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to split a string based on character(s) length
by thanos1983 (Parson) on Aug 13, 2014 at 20:35 UTC |