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

a) (5pt) Build a regular expression that captures any number in the following fo

ID: 3754639 • Letter: A

Question

a) (5pt) Build a regular expression that captures any number in the following formats:

3.1452926

-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) use the regular expression below to get the number of any type mentioned below

3.1452926

-212.45

126

1.9e10

In input_file you have to provide data and output_file contains the required numbers of given format.

car input_file.txt [-+]?[0-9]*.?[0-9]+([eE][+]?[0-9]+)? > output_file.txt

b)

by using -v we can get the grep command that is not matching with the given expression

cat input_file.txt | grep -v "for" > output_file