Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Mathematica - partition string into chunks?
I want to split a string in Mathematica into substrings of a given length so that, say, "ABCDEF" -> {"AB","CD","EF"}. I cannot think of a simple way to do this. Obviously I can write chunk[s_, n_] := StringJoin[#] & /@ Partition[Characters[s], n] but this seems unnecessarily long-winded. I'm sure there's an obvious and simple technique, but I can't spot it.
1 Answer
- Anonymous9 years agoFavorite Answer
The method you gave using Characters and Partition is quite a good one.
However there are some other possible ways which are described in detail on the Mathematica Stack Exchange community. Please follow this URL to see those options: