[asterisk-bugs] [Asterisk 0015223]: [patch] New asterisk function REPLACE
Asterisk Bug Tracker
noreply at bugs.digium.com
Wed Nov 18 11:20:40 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)
======================================================================
----------------------------------------------------------------------
(0113942) lmadsen (administrator) - 2009-11-18 11:20
https://issues.asterisk.org/view.php?id=15223#c113942
----------------------------------------------------------------------
PASSTHRU() works as expected.
-- Executing [200 at phones:2] Set("SIP/0004f2040001-00000000",
"count=1") in new stack
-- Executing [200 at phones:3] Set("SIP/0004f2040001-00000000",
"myString=this-is-my-custom-string") in new stack
-- Executing [200 at phones:4] Set("SIP/0004f2040001-00000000",
"totalFields=5") in new stack
-- Executing [200 at phones:5] NoOp("SIP/0004f2040001-00000000",
"--START--") in new stack
-- Executing [200 at phones:6] While("SIP/0004f2040001-00000000", "1") in
new stack
-- Executing [200 at phones:7] NoOp("SIP/0004f2040001-00000000", "this")
in new stack
-- Executing [200 at phones:8] Set("SIP/0004f2040001-00000000",
"count=2") in new stack
-- Executing [200 at phones:9] EndWhile("SIP/0004f2040001-00000000", "")
in new stack
-- Executing [200 at phones:6] While("SIP/0004f2040001-00000000", "1") in
new stack
-- Executing [200 at phones:7] NoOp("SIP/0004f2040001-00000000", "is") in
new stack
-- Executing [200 at phones:8] Set("SIP/0004f2040001-00000000",
"count=3") in new stack
-- Executing [200 at phones:9] EndWhile("SIP/0004f2040001-00000000", "")
in new stack
-- Executing [200 at phones:6] While("SIP/0004f2040001-00000000", "1") in
new stack
-- Executing [200 at phones:7] NoOp("SIP/0004f2040001-00000000", "my") in
new stack
-- Executing [200 at phones:8] Set("SIP/0004f2040001-00000000",
"count=4") in new stack
-- Executing [200 at phones:9] EndWhile("SIP/0004f2040001-00000000", "")
in new stack
-- Executing [200 at phones:6] While("SIP/0004f2040001-00000000", "1") in
new stack
-- Executing [200 at phones:7] NoOp("SIP/0004f2040001-00000000",
"custom") in new stack
-- Executing [200 at phones:8] Set("SIP/0004f2040001-00000000",
"count=5") in new stack
-- Executing [200 at phones:9] EndWhile("SIP/0004f2040001-00000000", "")
in new stack
-- Executing [200 at phones:6] While("SIP/0004f2040001-00000000", "1") in
new stack
-- Executing [200 at phones:7] NoOp("SIP/0004f2040001-00000000",
"string") in new stack
-- Executing [200 at phones:8] Set("SIP/0004f2040001-00000000",
"count=6") in new stack
-- Executing [200 at phones:9] EndWhile("SIP/0004f2040001-00000000", "")
in new stack
-- Executing [200 at phones:6] While("SIP/0004f2040001-00000000", "0") in
new stack
-- Executing [200 at phones:10] NoOp("SIP/0004f2040001-00000000", "--ALL
DONE--") in new stack
Hmmm... well it works as advertised, but I expected REPLACE() to replace a
string with another string.
i.e. I could replace 'abc' with 'ABC'.
Here is the output for REPLACE() in some tests (working as expected)
- Executing [100 at phones:2] Set("SIP/0004f2040001-00000000",
"originalVariable=123abc789xyzHELLO") in new stack
-- Executing [100 at phones:3] NoOp("SIP/0004f2040001-00000000",
"Standard test on numbers: Get '444abc789xyzHELLO'") in new stack
-- Executing [100 at phones:4] NoOp("SIP/0004f2040001-00000000",
"Standard test on string: Get '123yyy789xyzHELLO'") in new stack
-- Executing [100 at phones:5] NoOp("SIP/0004f2040001-00000000", "String
replace: Get '123abc789xyzhhhhh'") in new stack
-- Executing [100 at phones:6] NoOp("SIP/0004f2040001-00000000", "Case
match: Get '123abc789xyzHELLO'") in new stack
-- Executing [100 at phones:7] NoOp("SIP/0004f2040001-00000000", "Case
replace: Get '123Abc789xyzHELLO'") in new stack
Issue History
Date Modified Username Field Change
======================================================================
2009-11-18 11:20 lmadsen Note Added: 0113942
======================================================================
More information about the asterisk-bugs
mailing list