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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started