Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 2 (15 pts) a) Write a Ruby method for extracting the digits from Quebec Heath Insurance Card ID called HID_mum that given a string
Question 2 (15 pts) a) Write a Ruby method for extracting the digits from Quebec Heath Insurance Card ID called HID_mum that given a string str, uses regular expressions and back references to find the first valid card number in the string. A person valid health care number has 4 uppercase letters, followed by 8 digits number (e.g.: RENL18347692).The method should return the individual number as an integer value, or nil if no individual valid card number is found. Examples HID num HIDnum HID num ("SALZ 18 3 4 7 692 ("HOuN12345678 ("ChAP62148730 SA262487931") # returns 18347692 HOUN2 46 81 357") # returns 24681357 CHA62|48730") # returns nil - b) Write a Ruby program that reads the name of a text file from the command line, opens the file, reads every line of text in the file, that is a string pass it the method HID _num and prints only the lines that return an accepted number. If your text file contains the three lines above it should only give the first two returns
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started