Anonymous user
Strip a set of characters from a string: Difference between revisions
Strip a set of characters from a string (view source)
Revision as of 09:33, 9 June 2011
, 13 years agoadded standard ml
(added php) |
(added standard ml) |
||
Line 149:
<lang ruby>>> "She was a soul stripper. She took my heart!".delete("aei")
=> "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}}==
|