Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Handbook Of Relational Database Design

Authors: Candace C. Fleming, Barbara Von Halle

1st Edition

0201114348, 978-0201114348

More Books

Students also viewed these Databases questions

Question

=+7 How has the COVID-19 pandemic impacted the operations of IHRM?

Answered: 1 week ago