6 ms·
Question 9 appears to have two answers that are correct, but only one is accepted.
by ibdknox 9y ago
Question 9 appears to have two answers that are correct, but only one is accepted.
- StavrosK 9y agoYep, I just came here to post that: In [2]: re.search("b[l].e", "babel") In [3]: re.search("b[l].e", "blabber") Out[3]: <_sre.SRE_Match at 0x7f2db79ed030> It looks like they meant "match" as in "re.match", i.e. "^b[l].*e$", which is not the usual definition of the word.
- ibdknox 9y agoThat would also make this question specific to python, which wasn't at all what I was thinking about. It's a question about regular expressions, it should be as agnostic as possible to implementation.
- StavrosK 9y agoYeah, agreed, although there are different RE flavors, so you can't get too agnostic.
- ammon 9y agoHmm. Just checked again. Two of the expressions match neither word, one matches both, and one matches only one. EDIT: I see. The confusion is over partial match vs whole match. I thought whole matches were standard when talking about regular expression in the abstract, but looks like I was wrong. Just changed the problem to include the anchors. Thanks for pointing this out.
- ibdknox 9y agoThat's not the standard meaning in my experience. Regex's are often used for extracting information from larger strings, forcing a full match by default would be pretty counter to their purpose.