Question
Write regular expressions to match the following criteria and only the following criteria. Write regular expressions only, not Ruby code. (a) Any string that contains
Write regular expressions to match the following criteria and only the following criteria. Write regular expressions only, not Ruby code.
(a) Any string that contains an integer comprised of 3n + 1 digits, for n e N for example, these string match: "ur 8", "4002", "Ticket #3435947". These do not: "44th ain't bad.", "div-921", "[10230]"
(b) Any string whose entire contents are a septendecimal (Base-17) literal. Allow for either upper or lowercase letters.
(c) Any string that contains a block of test that begins with $$ and ends with $$. Match only a single block
(d) Any string whose entire contents are one the form CITY, State ZIP. STATE is a two letter state abbreviation. ZIP is either a 5-digit or ZIP+4 ZIP code. Capture the three pieces of information and only those three. For example, matching "Madison, New York 54703-1204" should capture "Madison", "NY", and "54703-1204"
(e) Any string that contains a sequence of space of tab characters at the end of a line. Match the whole sequence Such trialing spaces are a scourge.
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