[asterisk-bugs] [Asterisk 0015223]: [patch] New asterisk function REPLACE

Asterisk Bug Tracker noreply at bugs.digium.com
Wed Nov 18 11:20:53 CST 2009


A NOTE has been added to this issue. 
====================================================================== 
https://issues.asterisk.org/view.php?id=15223 
====================================================================== 
Reported By:                ajohnson
Assigned To:                lmadsen
====================================================================== 
Project:                    Asterisk
Issue ID:                   15223
Category:                   Functions/func_strings
Reproducibility:            N/A
Severity:                   feature
Priority:                   normal
Status:                     ready for testing
Target Version:             1.8
Asterisk Version:           SVN 
JIRA:                       SWP-283 
Regression:                 No 
Reviewboard Link:            
SVN Branch (only for SVN checkouts, not tarball releases):  trunk 
SVN Revision (number only!): 197994 
Request Review:              
====================================================================== 
Date Submitted:             2009-05-29 12:02 CDT
Last Modified:              2009-11-18 11:20 CST
====================================================================== 
Summary:                    [patch] New asterisk function REPLACE
Description: 
[Synopsis]
Replace a set of characters with another character in a given string


[Description]
Iterates through a string replacing all the <find-chars> with
<replace-char>.
NOTE: <replace-char> may be either empty or contain one character

[Syntax]
REPLACE(find-chars,replace-char,string)

====================================================================== 

---------------------------------------------------------------------- 
 (0113943) lmadsen (administrator) - 2009-11-18 11:20
 https://issues.asterisk.org/view.php?id=15223#c113943 
---------------------------------------------------------------------- 
Testing dialplan for above output:

exten => 100,1,NoOp()
exten => 100,n,Set(originalVariable=123abc789xyzHELLO)
exten => 100,n,NoOp(Standard test on numbers: Get
'${REPLACE(originalVariable,123,4)}')
exten => 100,n,NoOp(Standard test on string: Get
'${REPLACE(originalVariable,abc,y)}')
exten => 100,n,NoOp(String replace: Get
'${REPLACE(originalVariable,HELLO,hello)}')
exten => 100,n,NoOp(Case match: Get '${REPLACE(originalVariable,XYZ,x)}')
exten => 100,n,NoOp(Case replace: Get '${REPLACE(originalVariable,a,A)}')

exten => 200,1,NoOp()
exten => 200,n,Set(count=1)
exten => 200,n,Set(myString=this-is-my-custom-string)
exten =>
200,n,Set(totalFields=${FIELDQTY(PASSTHRU(this^is^my^custom^string),^)})
exten => 200,n,NoOp(--START--)
exten => 200,n,While($[${count} <= ${totalFields}])
exten => 200,n,NoOp(${CUT(PASSTHRU(${myString}),-,${count})})
exten => 200,n,Set(count=$[${count} + 1])
exten => 200,n,EndWhile()
exten => 200,n,NoOp(--ALL DONE--) 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2009-11-18 11:20 lmadsen        Note Added: 0113943                          
======================================================================




More information about the asterisk-bugs mailing list