Question: Revision questions on regular expressions in Linux a) Explain the difference between greedy and non-greedy quantifiers in regular expressions. Think carefully, and show the first

Revision questions on regular expressions in Linux

a) Explain the difference between greedy and non-greedy quantifiers in regular expressions. Think carefully, and show the first match (if any) that these patterns make:

[l - r] {5,9}?

[l - r]+?

[l - r]+

when applied to the string:

The poolroom is closed

b) Write regular expressions to match the following patterns embedded in a document and briefly explain the match:

i) words containing both 'to' and 'do' (e.g. toydom, dogtooth, torpedo, pseudoaristocratic)

ii) a Spanish car number plate (e.g. A561PBD, C194ZJK) where the last three letters cannot contain vowels or the letter Q.

iii) Prices in , $ or " the Euro " (COULD NOT FIND THE EURO SIGN ON MY KEYPAD, SORRY!! CAN YOU KINDLY PUT IT IN FOR ME TO REPLACE " the Euro " WHEREVER YOU SEE IT THANKS, if not please just ignore the Euro bit) between 100 and 1000 (e.g. 568.45, $234.00, or " the Euro " 400)

iv) A repeated sequence of the 4 digits followed by its reverse in a longer string of digits (e.g. 6239581234432185940)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!