Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

a.Build a regular expression that captures any number in the following formats:

ID: 3753981 • Letter: A

Question

a.Build a regular expression that captures any number in the following formats:

3.1452926

6 -212.45

126

1.9e10

For simplicity, assume only a nonnegative integer may appear after ‘e’. Use ‘.’ for symbol ‘.’

b. Build a regular expression that captures all non-empty sequences of letters other than “for”. For your convenience, you may use a “not” operator that takes a set of letters as argument and matches any other letter. For instance, not(abc) matches any letter other than a, b and c. Use ‘.’ to match any letter.

Explanation / Answer

a)

1)

[0-9][.][0-9][0-9][0-9][0-9][0-9][0-9][0-9]

2)

[0-9][-][0-9][0-9][0-9][.][0-9][0-9]

3)

[0-9][.][0-9][e][0-9][0-9]

b)

(?:[^for]*)