Strip a set of characters from a string: Difference between revisions
Content added Content deleted
m (tidy) |
(→Tcl: Added implementation) |
||
Line 64: | Line 64: | ||
>>> stripchars("She was a soul stripper. She took my heart!", "aei") |
>>> stripchars("She was a soul stripper. She took my heart!", "aei") |
||
'Sh ws soul strppr. Sh took my hrt!'</lang> |
'Sh ws soul strppr. Sh took my hrt!'</lang> |
||
=={{header|Tcl}}== |
|||
<lang tcl>proc stripchars {str chars} { |
|||
foreach c [split $chars ""] {set str [string map [list $c ""] $str]} |
|||
return $str |
|||
} |
|||
set s "She was a soul stripper. She took my heart!" |
|||
puts [stripchars $s "aei"]</lang> |