Partition(divid string to substring
- To: mathgroup at smc.vnet.net
- Subject: [mg60940] Partition(divid string to substring
- From: Sara <ma_sara177 at hotmail.com>
- Date: Tue, 4 Oct 2005 01:25:06 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
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. Thanks
- Follow-Ups:
- Re: Partition(divid string to substring
- From: Igor Antonio <igora@wolf-ram.com>
- Re: Partition(divid string to substring