Created
February 27, 2018 20:31
-
-
Save ryanckulp/4ca1defdfe1c05a69a26925285718bae to your computer and use it in GitHub Desktop.
sanitizes JP morgan string variants to singular intention
This file contains 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
str_a = 'j.p. morgan' | |
str_b = 'jp morgan chase' | |
str_a == str_b # => false | |
str = 'j.p. morgan' | |
str.downcase.gsub("j.p.", "jp").gsub("j.p", "jp").gsub("jp.", "jp").gsub("jp morgan", "jp morgan chase") # => "jp morgan chase" | |
def jp_morgan_chase?(str) | |
str.downcase.gsub("j.p.", "jp").gsub("j.p", "jp").gsub("jp.", "jp").gsub("chase", "").strip.gsub("jp morgan", "jp morgan chase") == "jp morgan chase" | |
end | |
jp_morgan_chase?(str) # => true | |
jp_morgan_chase?(str_a) # => true | |
jp_morgan_chase?(str_b) # => true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment