one way
str ss s="2 text[]4-6 text2[]8 text3"
foreach ss s
,int iii=findc(ss '-')
,if iii <>-1
,,ss=sub.getNumRange(ss)
,out ss
#sub getNumRange
function~ ~sss
int i ii
ARRAY(CHARRANGE) a
findrx(sss "(\d+)\-(\d+)\s(.+)" 0 4 a)
,for i 0 a.len
,,int offset1(a[1 i].cpMin) length1(a[1 i].cpMax-a[1 i].cpMin)
,,str sn.get(sss offset1 length1)
,,int offset2(a[2 i].cpMin) length2(a[2 i].cpMax-a[2 i].cpMin)
,,str en.get(sss offset2 length2)
,,int offset3(a[3 i].cpMin) length3(a[3 i].cpMax-a[3 i].cpMin)
,,str Etext.get(sss offset3 length3)
,for ii val(sn) val(en)+1
,,str results.formata("%i %s[]" ii Etext)
ret results.trim