In “aa67bc54c9”, is there any way to print “aa” 67 times, “bc” 54 times and so on, using regular expressions?

前端 未结 5 2089
谎友^
谎友^ 2020-12-15 14:13

I was asked this question in an interview for an internship, and the first solution I suggested was to try and use a regular expression (I usually am a little stumped in int

5条回答
  •  旧时难觅i
    2020-12-15 14:38

    Nope, this is your basic 'trick question' - no matter how you answer it that answer is wrong unless you have exactly the answer the interviewer was trained to parrot. See the workup of the issue given by Pavel Shved - note that all invocations have 'not' as a common condition, the tool just keeps sliding: Even when it changes state there is no counter in that state

    I have a rather advanced book by Kenneth C Louden who is a college prof on the matter, in which it is stated that the issue at hand is codified as "Regex's can't count." The obvious answer to the question seems to me at the moment to be using the lookahead feature of Regex's ...

    Probably depends on what build of what brand of regex the interviewer is using, which probably depends of flight-dynamics of Golf Balls.

提交回复
热议问题