Hi, Richard,

COFFRE Richard FTO wrote:
> 
> Hi Rebol fellows,
> 
> Is there a tip to quickly split a very long string more than
> 2000 characters into n characters sub strings and to create
> a list with these subsets ?
> For instance :
> 
...
> 
> I want to split this string into substrings of 5 characters...
> 

Here's a quick-and-dirty solution:

    >> longstring: "abcdefghijklmnopqrstuvwxyz"
    == "abcdefghijklmnopqrstuvwxyz"
    >> i: 1
    == 1
    >> stringblock: []
    == []
    >> while [i <= length? longstring] [
    [    append stringblock copy/part at longstring i 5
    [    i: i + 5
    [    ]
    == 31
    >> stringblock
    == ["abcde" "fghij" "klmno" "pqrst" "uvwxy" "z"]
    >>

-jn-

-- 
; Joel Neely                             joeldotneelyatfedexdotcom
REBOL [] do [ do func [s] [ foreach [a b] s [prin b] ] sort/skip
do function [s] [t] [ t: "" foreach [a b] s [repend t [b a]] t ] {
| e s m!zauafBpcvekexEohthjJakwLrngohOqrlryRnsctdtiub} 2 ]
-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to