All pastes #36737 Raw Edit

Something

public ini v1 · immutable
#36737 ·published 2006-01-13 22:31 UTC
rendered paste body
; FIXME: For testing clean-string macroexten => 8889,1,Set(testvar=123-456-7890)exten => 8889,n,Macro(clean-string,${testvar},-)exten => 8889,n,Answerexten => 8889,n,SayDigits(${CLEANSTRING})exten => 8889,n,Hangup[macro-clean-string]; Clean a specific character from a string; ${ARG1} -- String to clean; ${ARG2} -- Character to filter; Initialize our iterator and working varexten => s,1,Set(iter=0)exten => s,n,Set(working=${ARG1})exten => s,n,Goto(s-ITER,1); Increment our iteratorexten => s-ITER,1,Set(iter=$[${iter} + 1]); Set the result to the current block (based on iterator)exten => s-ITER,n,Set(result=${result}${CUT(ARG1,${ARG2},${iter})}); Update our working set to be everything except current blockexten => s-ITER,n,Set(working=${CUT(ARG1,${ARG2},$[${iter} + 1]-)}); If it still contains a character to clean, restart the loopexten => s-ITER,n,GotoIf($[${working} : ".*?${ARG2}.*"]?s-ITER,1); Don't forget the last blockexten => s-ITER,n,Set(result=${result}${working}); We're done processingexten => s-ITER,n,Goto(s-DONE,1); Set a channel variable with the cleaned stringexten => s-DONE,1,Set(_CLEANSTRING=${result})exten => s-DONE,n,NoOp(New variable: ${result})