Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Partition(divid string to substring

  • To: mathgroup at
  • Subject: [mg60951] Re: Partition(divid string to substring
  • From: "Jens-Peer Kuska" <kuska at>
  • Date: Wed, 5 Oct 2005 02:27:51 -0400 (EDT)
  • Organization: Uni Leipzig
  • References: <dht4h7$hnr$>
  • Sender: owner-wri-mathgroup at


I also don't know how to use StringTake[] and I 
don't know what the
For[] loop does and what the empty Module[{},___] 
may be mean but

StringPartition[str_String, n_Integer] :=
  StringJoin @@@ Partition[PadRight[Characters[#], 
StringLength[#] + n - Mod[StringLength[#], n], " 
"], n] &[str]

may help you, without  For[], StringTake[] or 


"Sara" <ma_sara177 at> schrieb im 
Newsbeitrag news:dht4h7$hnr$1 at
|I have to canstruct a method stringPartition[s,n] 
that divides a string s into substrings of length 
n. The last string shall be filled with spaces to 
the specified length.and I have too use 
StringTake. But i have done it Like that:
| stringPartition[s_, n_] := Module[
|    {},
|    emptyString = Mod[StringLength[s], n];
| If[emptyString â? 0, empt = n - emptyString];
| str1 := " ";
| str2 := "";
| For[i = 1, i â?¤ empt, i++,
|      str2 = str2 <> str1];
|    str = s <> str2;
|    strCode = ToCharacterCode[str, "UTF8"];
|    textPartition = Partition[strCode, n];
|    textCode = FromCharacterCode[textPartition, 
|    ]
| and its work, but I dont know how to use 
Stringtake instead (toCharacterCode), I dont want 
to use  Toharachtercode.
| Thanks

  • Prev by Date: Re: the faster way to find repeated sublists
  • Next by Date: graphs
  • Previous by thread: Re: Partition(divid string to substring
  • Next by thread: "Mathematica in Education and Research"