Regexp question

B

bcparanj

I have a list of zip codes (3000). Is there any script that I could
use to create a regexp for checking if a user entered zip is in this
list or not? TIA.
 
D

darren kirby

quoth the (e-mail address removed):
I have a list of zip codes (3000). Is there any script that I could
use to create a regexp for checking if a user entered zip is in this
list or not? TIA.

Doubtful you need a regexp. Answer depends on the format of your list. If it
is a separate file with one code per line you could do:

codes = IO.readlines("/path/to/codes").each { |line| line.chomp! }
codes.include?(90210.to_s)

or if you have ZIP + 4 codes:

codes.include?("90210-1234")

-d
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top