-
-
Save zachad/5987889 to your computer and use it in GitHub Desktop.
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
# big_array has over 120,000 strings in it | |
def select_search(q) | |
big_array.select do |s| | |
s =~ /^#{Regexp.esecap(q)}/ | |
end | |
end | |
def grep_search(q) | |
big_array.grep( /^#{Regexp.escape(q)}/ ) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment