string-replacement function install
This commit is contained in:
parent
9a1cbbe689
commit
6e4ffff3e8
|
@ -1,6 +1,22 @@
|
||||||
N I
|
;https://www.isharkfly.com/t/mumps-string-replacement/15228/1N I
|
||||||
N TOK
|
READ !,"Enter String:", address
|
||||||
N OSTR
|
READ !,"Old String:", old
|
||||||
S count=0
|
READ !,"New String:", new
|
||||||
F I=1:1:$L(str," ") S TOK=$P(str," ",I) S:TOK=old TOK=new S:TOK=new count=count+1 S OSTR=$G(OSTR)_" "_TOK
|
DO strReplace(address,old,new,.count)
|
||||||
QUIT $E(OSTR,2,$LENGTH(OSTR))
|
WRITE !, count
|
||||||
|
QUIT
|
||||||
|
strReplace(str,old,new,count)
|
||||||
|
SET count=0
|
||||||
|
SET position=0
|
||||||
|
|
||||||
|
FOR {
|
||||||
|
SET position=$FIND(str, old, position)
|
||||||
|
QUIT:position=0
|
||||||
|
SET count=count+1
|
||||||
|
SET position=position
|
||||||
|
}
|
||||||
|
|
||||||
|
WRITE !,count
|
||||||
|
SET str = $replace(str,old, new)
|
||||||
|
WRITE !, str
|
||||||
|
QUIT
|
||||||
|
|
Loading…
Reference in New Issue