Strip a set of characters from a string: Difference between revisions

Added solution for Action!
(Added solution for Action!)
Line 206:
 
<pre>Sh ws soul strppr. Sh took my hrt!</pre>
 
=={{header|Action!}}==
<lang Action!>PROC Strip(CHAR ARRAY text,chars,res)
BYTE i,j,size,found
CHAR c
 
size=0
FOR i=1 TO text(0)
DO
c=text(i) found=0
FOR j=1 TO chars(0)
DO
IF c=chars(j) THEN
found=1 EXIT
FI
OD
IF found=0 THEN
size==+1
res(size)=c
FI
OD
res(0)=size
RETURN
 
PROC Main()
CHAR ARRAY
text="She was a soul stripper. She took my heart!",
chars="aei", result(255)
 
Strip(text,chars,result)
PrintE("String to be stripped:")
PrintF("""%S""%E%E",text)
PrintE("Characters to be stripped:")
PrintF("""%S""%E%E",chars)
PrintE("Stripped string:")
PrintF("""%S""%E%E",result)
RETURN</lang>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Strip_a_set_of_characters_from_a_string.png Screenshot from Atari 8-bit computer]
<pre>
String to be stripped:
"She was a soul stripper. She took my heart!"
 
Characters to be stripped:
"aei"
 
Stripped string:
"Sh ws soul strppr. Sh took my hrt!"
</pre>
 
=={{header|Ada}}==
Anonymous user