Given the regular expression ABCAB find all the matching pat

Given the regular expression: ^[ABC][^AB]$ find all the matching patterns (could be more than one):

a) A

b) AB

c) ADBC

d) D

e) None

Solution

^ : Starting position in a string.

[] : Matches a single character that is contained within the brackets

^[ABC] : Starting position should contain \'A\' or \'B\' or \'C\'

[^ ] : Matches a single character that is not within the characters contained in brackets

$: Matches ending position of string

[^AB]$ : Ending position of character should not be in \'A\' or \'B\'

Hence

A is not a match because reg exp requires 2 characters

D is also eliminated

ADBC is also because required length is 2

AB is not a valid match because last character hould not be in A or B

Hence the answer is None

Given the regular expression: ^[ABC][^AB]$ find all the matching patterns (could be more than one): a) A b) AB c) ADBC d) D e) NoneSolution^ : Starting position

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site