Question: 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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!