Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON REGULAR EXPRESSIONS (2A and 2B are related to each other, please answer ALL parts) For #2A only: write and submit a one line file.

PYTHON REGULAR EXPRESSIONS (2A and 2B are related to each other, please answer ALL parts)

For #2A only: write and submit a one line file. The line should start with the ^ character and end (on the same line) with the $ character. The contents of that one line should be exactly what you typed-in/tested in the online Regular Expression checker.

image text in transcribedimage text in transcribed

2a. (4 pts) When we print computer documents, there is a common form used to specify the page numbers to print. Generally, commas separate page specifications, where each page specification is a single page number, or a contiguous range of pages. In a page specification, a dash or a colon can separate two numbers for a dash, these numbers specify the first and last pages in a range to print (inclusive); for a colon, they specify the first page and how many subsequent pages to print (so 10:3 means 3 pages starting at 10: 10, 11, and 12). Finally, if either of these forms is used, we can optionally write a slash followed by a number (call it n), which means for the page specification, print every n page in the range (so 10-20/3 means 10 through 20 , but only every 3" page: 10, 13, 16, and 19). Write a regular expression that ensures group 1 is the first page; group 2 is a dash or colon (or None if not present); group 3 is the number after the dash or colon (or None if not present); group 4 is the number after the slash (or None if not present) Write a regular expression pattern that describes a single page specification: the integers you specify here must start with a non-0 digit. Here are examples that should match/should not match a single page specification: Match3 and 5-8 and 12:3 and 5-8 and 6:4 and 10-20/3 and 10:10/3 Not Match 03 and 5-08 and 3 4 and 3 to 8 and 4/3 and 4-:3 and 4-6:3 2a. (4 pts) When we print computer documents, there is a common form used to specify the page numbers to print. Generally, commas separate page specifications, where each page specification is a single page number, or a contiguous range of pages. In a page specification, a dash or a colon can separate two numbers for a dash, these numbers specify the first and last pages in a range to print (inclusive); for a colon, they specify the first page and how many subsequent pages to print (so 10:3 means 3 pages starting at 10: 10, 11, and 12). Finally, if either of these forms is used, we can optionally write a slash followed by a number (call it n), which means for the page specification, print every n page in the range (so 10-20/3 means 10 through 20 , but only every 3" page: 10, 13, 16, and 19). Write a regular expression that ensures group 1 is the first page; group 2 is a dash or colon (or None if not present); group 3 is the number after the dash or colon (or None if not present); group 4 is the number after the slash (or None if not present) Write a regular expression pattern that describes a single page specification: the integers you specify here must start with a non-0 digit. Here are examples that should match/should not match a single page specification: Match3 and 5-8 and 12:3 and 5-8 and 6:4 and 10-20/3 and 10:10/3 Not Match 03 and 5-08 and 3 4 and 3 to 8 and 4/3 and 4-:3 and 4-6:3

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_2

Step: 3

blur-text-image_3

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

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

9. I fear death very much now.

Answered: 1 week ago

Question

Do you think the banquet is a ritual? Why or why not?

Answered: 1 week ago