Created
December 9, 2015 18:28
-
-
Save edenthecat/2babbba41236de3d568d to your computer and use it in GitHub Desktop.
Ruby: Remove Filtered Characters from a String
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def filterString | |
originalString = "Hello this is dog" | |
filter = "Hdgol" | |
puts "the original string is " + originalString | |
puts "filter: " + filter | |
splitString = originalString.split(//) | |
splitFilter = filter.downcase.split(//) | |
for i in splitFilter | |
splitString.delete(i) | |
splitString.delete(i.upcase) | |
end | |
puts splitString.join() | |
end | |
filterString |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment