Write a regular expression that can match a string that starts with at least 2, but...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a regular expression that can match a string that starts with at least 2, but no more than 4 digits, contains substrings aa or bb followed by at least one digit. However, the string cannot end with such a substring! The match should be case insensitive. For example, the following strings are valid: 10GhaA345c, 224Zui2bb7@ String aa3c or 1aa345c is incorrect, because it doesn't start with at least two digits. Strings 12Ghaa345 is incorrect because it ends with a matching substring aa345. String 13454Ghbb3a is incorrect because it starts with more than 4 digits. String 13Ghab3a is incorrect because it doesn't have substring aa or bb. String 12Ghaac is incorrect because it doesn't have at least one digit after aa. Requirements: Your solution must be as simple and as short as possible. Important!: String 11aa345aa3 is correct even though it has two substrings: aa345 and aa3. If you focus on the first substring aa345 then all the requirements are met. If you consider the second substring aa3 then the requirement not to have such substring at the end of the string will not be satisfied. However, since you need to find at least one matching substring, this ambiguous string will be correct. Hints: To allow case-insensitive matches please make sure you use the correct REGEX flags at the end of the regular expression. Do NOT use unnecessary flags. Do NOT use lookahead/lookbehind patterns! Your solution won't be optimal. Use shortcut \d for digits [0-9]. Write a regular expression that can match a string that starts with at least 2, but no more than 4 digits, contains substrings aa or bb followed by at least one digit. However, the string cannot end with such a substring! The match should be case insensitive. For example, the following strings are valid: 10GhaA345c, 224Zui2bb7@ String aa3c or 1aa345c is incorrect, because it doesn't start with at least two digits. Strings 12Ghaa345 is incorrect because it ends with a matching substring aa345. String 13454Ghbb3a is incorrect because it starts with more than 4 digits. String 13Ghab3a is incorrect because it doesn't have substring aa or bb. String 12Ghaac is incorrect because it doesn't have at least one digit after aa. Requirements: Your solution must be as simple and as short as possible. Important!: String 11aa345aa3 is correct even though it has two substrings: aa345 and aa3. If you focus on the first substring aa345 then all the requirements are met. If you consider the second substring aa3 then the requirement not to have such substring at the end of the string will not be satisfied. However, since you need to find at least one matching substring, this ambiguous string will be correct. Hints: To allow case-insensitive matches please make sure you use the correct REGEX flags at the end of the regular expression. Do NOT use unnecessary flags. Do NOT use lookahead/lookbehind patterns! Your solution won't be optimal. Use shortcut \d for digits [0-9].
Expert Answer:
Answer rating: 100% (QA)
Certainly Heres a regular expression that meets the gi... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
For stock and mutual fund investments only, research back to fair market value share price (or net asset value) one year ago, five years ago, and ten years ago. If you would have invested the same...
-
Extend Your enjoyment Welcome to Cunningham Gudgal Golf Resort Background Information Cunningham Holdings Limited is a diversified family owned business. For more information about the company see...
-
Extend Your enjoyment Welcome to Cunningham Gudgal Golf Resort Background Information Cunningham Holdings Limited is a diversified family owned business. For more information about the company see...
-
In Problems 1130, solve each equation by factoring. x 2 - 9x = 0
-
Is it necessary to compute the real range to construct a frequency distribution for (a) Ungrouped data (b) Grouped data?
-
In 1938, R. N. Elliott proposed a theory that equity markets move: A. In stochastic waves. B. In cycles following Fibonacci ratios. C. In waves dependent on other securities.
-
\(7.2 \pi+8.6 \pi\) Perform the arithmetic operations without a calculator, if possible. If it is not possible, state why.
-
The following data are from the income statements of Haskin Company. (a) Compute for each year (1) The inventory turnover (2) The days in inventory. (b) What conclusions concerning the management of...
-
8. A construction company is negotiating on a construction project with a six-month duration. On the last day of each month the construction company may bill the owner for the work completed during...
-
The Chartered Financial Analyst (CFA) designation is the de facto professional certification for the financial industry. Employers encourage their prospective employees to complete the CFA exam....
-
Which of the following is a characteristic unique to a Type 1 hypervisor? A. Memory is directly controlled by the hypervisor B. There is support for two or more operating systems to run...
-
What would your payment be on a 10-year, $150,000 loan at 10% interest compounded semiannually assuming the payments are made annually?
-
Susi is thinking of opening a grill business cafe (grilled/grilled). He estimates that it will cost Rp 500 million per year to rent a place, to buy baking utensils and buy other ingredients. But he...
-
(8 points) Let A = [ 3 ] 9 2 6 8 and B = 7 4 Find the matrix C of the linear transformation defined by T(x) = B(Ax). C =
-
What is the main function of a managerial accountant? 2. Explain the four management functions. 3. Differentiate managerial and financial accounting.
-
You have $1,225 in a savings account which earns 8.4% compounded monthly and $1,300 in an account which earns 6% compounded monthly. How many years will it be until the two accounts have the same...
-
Dani Corporation has 4.1 million shares of common stock outstanding. The current share price is $88.00, and the book value per share is $10.50. The company also has two bond issues outstanding. The...
-
Determine whether the lines are parallel, perpendicular, or neither. 2x + 3y = -12, 2y - 3x = 8
-
Deborah purchases a new $30,000 car in 2012 to use exclusively in her business. If Deborah does not elect to expense or take bonus depreciation in 2012 and holds the car until it is fully...
-
Quince Interests is a partnership with a tax year that ends September 30, 2012. During that year, Potter, a partner, received $3,000 per month as a guaranteed payment, and his share of partnership...
-
Jim (age 50) and Martha (age 49) are married with three dependent children. They file a joint return for 2012. Their income from salaries totals $50,000, and they received $10,000 in taxable...
-
Today mutual funds are very popular investment options. However, since their origin in 1924, they have fallen in and out of favor. Write About It Research and write a one-page essay on the history of...
-
You own 12 20-year General Electric Capital Services corporate bonds with face values of $1,000. Their coupon rate is 7.5%. Their current yield is 5.2%. 1. Calculate (a) What is the current market...
-
The prospectus of a mutual fund is where you fi nd out about the structure, fees, and rules of investing in the fund.
Study smarter with the SolutionInn App