Which two matches would be returned by this expression?

Evaluate the following expression using meta character for regular expression:
‘[^Ale|ax.r$]’
Which two matches would be returned by this expression? (Choose two.)

Evaluate the following expression using meta character for regular expression:
‘[^Ale|ax.r$]’
Which two matches would be returned by this expression? (Choose two.)

A.
Alex

B.
Alax

C.
Alxer

D.
Alaxendar

E.
Alexender



Leave a Reply 10

Your email address will not be published. Required fields are marked *


TNK

TNK

can anyone explain above question plz…

TNK

TNK

‘[Ale|ax.r$]’ is equal to ‘[Al(e|a)x.r$]’ am i correct?

Igor

Igor

I think that ‘^’ in this statement [^Ale|ax.r$] is a mistake. Because otherwise the answer is incorrect.

Djamel

Djamel

I think this function regexp_like respond the question :

select case when regexp_like (string,'[^Ale|ax.r$]’) then ‘MATCH’ else ‘NO MATCH’ end as output from dual;
string is A, B, C or D therefore D and E is response.
Thanks.

dames

dames

D and E
1) Pattern ‘[Aleaxr$]’ matches all characters in A to E, except characters ‘n’ and ‘d’ in D and E.
2) [^ (caret sign after opening square brackets), means “not equals”,
which INVERSES the matches found in 1), thus excluding A,B,and C.

Sandhya

Sandhya

‘[^Al(e|a)x.r$]

^ : start of string should be “Al”
| : after Al, character should be either “e or a”
$ : end of the string should be “r”

so answer D, E are correct.

Luk

Luk

I am sure that the question is defective. The [] makes it a set. But you cant use the “|”(or) Operation in a set.

CASE 1)
So lets say the [] is the fault. Then we search for that pattern: ‘^Ale|ax.r$’.
So we have an initial A followed by l, followed by either e or a, followed by x, followed by a random sign, followed by an r which has to be the last sign as well.
Non of A-E is matching this pattern.

CASE 2)
Lets say the | is the fault. Then we search for a word not containing of any of the following signs A l e a x . r $ (because ^ in a the beging of a “[]” negotiates). Any not empty word (NULL) wouldnt be matched by that because it would contain at least “.” as “any sign”.

To put that in a nutshell: The question is retarded.

abm

abm

It appears that answer is actually right. Check yourself, for example here: livesql.oracle.com
Since the string is given in brackets []. It is not a string it’s a matching list. which means that characters can be placed in any order.
[^] – negates expression. which equals to anything but…
| and $ within [] – mean nothing, so you can just ignore them

So basically expression equals to “anything that has more than just letters A l e a x r. And there just 2 values that qualify for that ‘Alaxendar’ and ‘Alexender’ since they have letters ‘n’ and ‘d’.

select * from
(SELECT ‘Alex’ a from dual
union all
SELECT ‘Alax’ from dual
union all
SELECT ‘Alxar’ from dual
union all
SELECT ‘Alaxendar’ from dual
union all
SELECT ‘Alexender’ from dual
)
where regexp_like(a,'[^Ale|ax.r$]’)

A
Alaxendar
Alexrende

2 rows selected.

lj

lj

I think, you have the right explanation. thanks

networkmanagers

networkmanagers

I choose