Question
Revision questions on Regular Expressions a) Explain the difference between greedy and non-greedy quantifiers in regular expressions. Think carefully, and show the first match (if
Revision questions on Regular Expressions
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. Briefly explain the match:
i) .+[a-f]
ii) .*?[a-f]
iii) .+?[a-f]
when applied to the string:
1476707729-5804c5642b2cf-52590
b) Write regular expressions to match the following patterns embedded in a document and briefly explain the match:
i) numbers between 99 and 9999999 (inclusive) with optional commas (e.g. 1,250)
ii) a national insurance number ( e.g. XP145237B or GG540672Y),
iii) words containing both 'in' and 'of' (e.g. spoofing, inoffending, kinofluous, coffin)
iv) five letter palindromes (words that are the same backwards as forwards) (e.g. kayak, dewed, refer)
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