Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Arrays reverse order, splitting one line of strings
#2
Macro Macro3208
Code:
Copy      Help
out
_s =
;I'm in the first line
;I'm the second line
;I'm in the third line #foo #ball

ARRAY(str) a=_s

;get and remove the #... part of the last line
str tail
str& last=a[a.len-1]
int j=findcs(last "?=#"); if(j>=0) tail.get(last j); last.left(last j); last.trim

;reverse
for(int'i 0 a.len/2) a[i].swap(a[a.len-i-1])
if(j>=0) a[]=tail

;join
str d=a[0]
for _i 1 a.len
,d.formata(" %s" a[_i])
out d


Messages In This Thread
RE: Arrays reverse order, splitting one line of strings - by Gintaras - 07-21-2022, 12:18 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)