Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Check to see if an array includes any part of the given search value.
# %w(abd def ghi).fuzzy_include? 'definition' # => true
class Array
def fuzzy_include?(search_value, regex_format = '%s')
inject(false) do |is_found, array_value|
is_found or !!(search_value =~ /#{regex_format % array_value}/)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.