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

Content added Content deleted
(added php)
(added standard ml)
Line 149: Line 149:
<lang ruby>>> "She was a soul stripper. She took my heart!".delete("aei")
<lang ruby>>> "She was a soul stripper. She took my heart!".delete("aei")
=> "Sh ws soul strppr. Sh took my hrt!"</lang>
=> "Sh ws soul strppr. Sh took my hrt!"</lang>

=={{header|Standard ML}}==
<lang sml>fun stripchars (string, chars) = let
fun aux c =
if String.isSubstring (str c) chars then
""
else
str c
in
String.translate aux string
end</lang>

testing in the interpreter:

<pre>- stripchars ("She was a soul stripper. She took my heart!", "aei") ;
val it = "Sh ws soul strppr. Sh took my hrt!" : string</pre>


=={{header|Tcl}}==
=={{header|Tcl}}==