I apologize when i posted 1st time i was half asleep and the initial post wont work for all circumstances
if the user is the last line of the string this won't work.
Macro Example String Replacement
so use either this
Macro Example String Replacement1
or use this
Macro Example String Replacement2
Example String Replacement2 needs the function below
Member function str.RemoveLineN
if the user is the last line of the string this won't work.
Macro Example String Replacement
;;;simulates the info received from webpage
str accountList = "account1[]account2[]account3[]account4[]account5"
str getAccount = "account5"
getAccount +"[]"
accountList.replacerx(getAccount "" 8)
out accountList
so use either this
Macro Example String Replacement1
;;;simulates the info received from webpage
str accountList = "account1[]account2[]account3[]account4[]account5"
str getAccount = "account5"
ARRAY(str) arr
int i nt
nt = tok(accountList arr)
for(i 0 nt)
,if arr[i]= getAccount
,,int rs=i
arr.remove(rs)
accountList=arr
accountList.trim
out accountList
or use this
Macro Example String Replacement2
;;;simulates the info received from webpage
str accountList = "account1[]account2[]account3[]account4[]account5"
str getAccount = "account5"
str s
int x
foreach s accountList
,if getAccount = s
,,accountList.RemoveLineN(x)
,x+1
accountList.trim
out accountList
Example String Replacement2 needs the function below
Member function str.RemoveLineN
function# lineindex [nlines]
;Removes specified line(s).
;Returns index of first character of lineindex-th line, or -1 if lineindex is too big.
;lineindex - zero-based line index.
;nlines - number of lines to remove. Default or 0: 1 line.
;EXAMPLE
;str s="zero[]one[]two"
;s.RemoveLineN(1)
;out s
if(nlines<1) nlines=1
int i=findl(this lineindex)
if(i>=0) this.remove(i findl(this+i nlines))
ret i