CSc 250: Lab 11

All Problems

If you cannot complete the lab in the alloted lab time, finish at home. You will be writing a number of regular expressions for the first few problems. Place all of your regex into a file named lab11.txt. Put a comment of the form:

### Problem X

Above each of the regex expressions. You’ll also be using regex101.com for the first several problems. Go to the site, and make sure to switch to python mode, and enable the multi-line setting.

Problem 1

In this problem (and the next few) you’ll be writing regular expressions to match various peices of text in the below text:

Poland with Russia, but not to cross the Vistula. Stein 
opposed this aggrandizement of Russia, and laboured to 
secure for Germany her old frontiers of the Vosges and 
the Meuse. In a memoir dated November 17, 18 12, he 
called on Alexander to act as the liberator of Germany.

Go to regex101.com and copy this text into the test string area. Write a regular expression to match the following text:

Problem 2

Using the same test string as the last problem, write a regular expression to match the following text:

Problem 3

Using the same test string as the last problem, write a regular expression to match the following text:

Problem 4

Using the same test string as the last problem, write a regular expression to match the following text:

Problem 5

In this problem (and the next few) you’ll be writing regular expressions to match various peices of text in the below text:

On March 14 the Duke of Mecklenburg 
joined the league. Gneisenau brought promises of help 
from England, with arms, provisions, and clothing for 
20,000 men, and the promise of the possible landing of an 
Anglo-Swedish army. On March 16, 1813, the French 
Ambassador, Saint Marsan, received the Prussian declara- 
tion of war, and on the following day appeared the famous 
appeal of King Frederick William III to his people: 
"Brandenburgers, Prussians, Silesians, Pomeranians, Lithu- 
anians, you know what you have suffered for the last 
seven years, you know what your miserable lot will be if 
the struggle, which now begins, does not end with honour.

Go to regex101.com and copy this text into the test string area. Write a regular expression to match the following text:

Problem 6

Using the same test string as the last problem, write a regular expression to match the following text:

Problem 7

Using the same test string as the last problem, write a regular expression to match the following text:

Problem 8

In this problem you’ll be writing regular expressions to match various peices of text in the below text:

Mixing Mix
Listing List
Singing Sing
-------
mixing MIX
Snooze Snooze
Sniize Snoozing
Sing ing Sing
SINGING sing
listing List
listing listing

Go to regex101.com and copy this text into the test string area. Write a regular expression to match the following text:

Problem 9

In this problem you’ll be writing regular expressions to match various peices of text in the below text:

look t this sentence
look at
did you look at this sentence
the sky is blue
we are human beings
-------
we are currently human beings
this is a long song
look not at this sentence
hi
this is a longer sentence than the other ones

Go to regex101.com and copy this text into the test string area. Write a regular expression to match the following text:

Problem 10

In this problem you’ll be writing regular expressions to match various peices of text in the below text:

A1B2C3
B7B7B7B7B7B7
C3P0
R2D2
-------
r2d2
c3p0
1A77B901C
7HI4How1Areyou

Go to regex101.com and copy this text into the test string area. Write a regular expression to match the following text:

Solutions