2) Write 3 regular expressions for the following instances: a) Will match agains
ID: 3889398 • Letter: 2
Question
2) Write 3 regular expressions for the following instances:
a) Will match against a pattern consisting of an uppercase or lowercase d or m, followed by an optional [aA] and/or an optional 0, followed by 5 digits between 1 and 9. For example, D070779, m52234, DA20234 are valid patterns, but P034923 and d05212 are not.
b) Matches against an IPv4 address in dotted-quad notation.
c) Matches against a MAC address. MAC addresses are 48-bits addressed typically written as 6 bytes represented in hexadecimals, separated by either colon (:) or dash (-). For example, a valid MAC addresses are 00:18:8b:49:16:98, and 0a-00-27-00-00-01.
Explanation / Answer
2)a)THE REQUIRED REGULAR EXPRESSION FOR THE 2A IS [d|D|M|m]{1}[a|A|0]?[1-9]{1}[0-9]{4}
b)THE REQUIRED REGULAR EXPRESSION FOR THE 2B IS
c)THE REQUIRED REGULAR EXPRESSION FOR THE 2C IS
([0-9A-Fa-f]{2}[-:]){5}([0-9A-Fa-f]{2})
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.