MathGroup Archive 2005

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

Search the Archive

Partition(divid string to substring

  • To: mathgroup at
  • Subject: [mg60940] Partition(divid string to substring
  • From: Sara <ma_sara177 at>
  • Date: Tue, 4 Oct 2005 01:25:06 -0400 (EDT)
  • Sender: owner-wri-mathgroup 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, "UTF8"]
and its work, but I dont know how to use Stringtake instead (toCharacterCode), I dont want to use  Toharachtercode.

  • Prev by Date: Re: How to "search" in a matrix?
  • Next by Date: Re: BinCounts
  • Previous by thread: Re: partitioning a string
  • Next by thread: Re: Partition(divid string to substring