09-02-2014, 01:42 PM
Macro Macro2342
out
str s=
;Hello,
;
;I have a text in a string, like 400 characters, i want this splitted in 3 strings of 150 characters. So i have finally 2 strings of 150 characters and 1 of 100.
;And if it's possible, the split must be done before the whole word (a space character) so the length of a string can vary but never more than 150 characters.
;
;i don't know how to do this, is somebody here who can help me out?
ARRAY(str) a
;if(!findrx(s "(?s)(.{1,150}\b)" 0 4 a)) end "failed"
if(!findrx(s "(?s)(.{1,150})(?:\s+|$)" 0 4 a)) end "failed"
int i
for i 0 a.len
,out a[1 i].len
,out a[1 i]