Regex (regular expressions) are a special datatype in Ruby that allows you to declare a pattern that can be used to match other objects like strings. This is an example of declarative programming that we talked about earlier in the week, because you're just specifying the results that you'd like to see, not telling the computer how to do it.
Fork/clone this repo. In the end, do a pull request (PR) to turn in the assignment.
Run bundle install from the terminal in this folder to ensure that you have
the proper Gems installed.
- Use
@source_textas your data source for extracting data. Do not edit this file. - Extract all valid IP addresses into an array returning from the
valid_ip_addressesmethod- (format for valid IP address is xxx.xxx.xxx.xxx)
- Extract all valid IP addresses from MIT into an array returning from the
valid_mit_ip_addressesmethod- (format 18.xxx.xxx.xxx)
- From this data, create an array of non-MIT IP addresses from the
non_mit_ip_addressesmethod - Extract unique valid US phone numbers into an array returning from the
valid_phone_numbersmethod - Extract the valid area code into an array returning from the
area_codesmethod.- (US area codes cannot begin with 0 or 1)
- Extract the email addresses into an array returning from the
email_addressesmethod.- (format X@Y.Z)
- Extract the valid zip codes into an array returning from the
zip_codesmethod. - Extract the valid hex colors into an array returning from the
hex_colorsmethod.
Run rspec spec to check if your main.rb has the right results.
Quick blog post on Regexes:
http://www.joshondesign.com/2011/04/12/joshs-quick-intro-to-regex/
Rubular - an awesome real-time regex editor for Ruby
RegExr - another regex editor, rollover an expression or match to see a detailed explanation
