下面的正则表达式将匹配以下哪些字符串?

时间:2015-02-10 16:59:45

标签: php regex

我只参加15个问题的考试。我顺利回答了15个问题中的11个问题,但现在我必须回答关于正则表达式的4个问题(不是我的强项)。

所以,第一个问题:

Which of the following strings will be matched by the regex below?
$regex = '/^\d+[a-c]{2,4}$/';

a. ab12cd
b. 1234a
c. 12ab34
d. 1234abc
e. 1a2b3c

第二个问题:

Which of the following strings will be matched by the regex below? (choose two)
/^\d([a-i]|\d)\w+$/

a. 3x3
b. 12ab
c. 3hree
d. ab12cd
e. 1two3

第三个问题

Which of the following are true regarding the regex below? (choose two)
/^\d([a-z]+)\d{2}/

a. the reggex doesn't contain any subpatterns
b. subpattern number 1 is ([a-z]+)
c. subpattern number 0 is ([a-z]+)
d. the regex contains two subpatterns: ([a-z]+) and {2}
e. the regex contains one subpattern: ([a-z]+)

最后一个:

Which of the following are NOT true about the code section below? (choose two)
$regex = '/\d.[13]/';

a. the [13] character class will match the number 13
b. the [13] character class will match either 1 and 3
c. the regex matches strings that have a lenght of 13 characters
d. \d is a character class that indicates a digit
e. the regexx matches strings that contain only digits

是期末考试,我有最后一次机会。请帮帮我!

0 个答案:

没有答案