Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Tip for splitting very long string ?

From: brett:codeconscious at: 15-Apr-2002 20:04

A couple of possibilities to check out below. str: copy "azertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbn" string-split-up1: function [ string [string!] n [integer!] ][result subrule][ if lesser? n 1 [return none] result: make block! divide length? str n subrule: compose [1 (n) skip] parse/all str [any [copy text subrule (insert tail result text)]] result ] string-split-up2: function [string [string!] n [integer!]][result][ if lesser? n 1 [return none] result: make block! divide length? str n forskip string n [insert tail result copy/part string n] result ] string-split-up1 str 5 If your string/list is very long you might wan't to avoid making the block (or list) in order not to waste time with memory allocations. Regards, Brett. ----- Original Message ----- From: "COFFRE Richard FTO" <[richard--coffre--francetelecom--com]> To: <[rebol-list--rebol--com]> Sent: Monday, April 15, 2002 7:24 PM Subject: [REBOL] Tip for splitting very long string ? 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 : str: copy "azertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbn" I want to split this string into substrings of 5 characters to have a-list: [ "azert" "yuiop" "qsdfg" "hjklm" ...] TIA Richard Coffre France Telecom Orbiscom TÚl. : 01 47 61 46 28