From WhizLabs prep exam 4, question 2
I know what "a{3}" means and so I thought the
string would be split thus: "[aaa][aaa][aaa]bb". Giving 3 Strings in the s array with values of "", "" and "bb".
I was wrong. The answer was 4, but WhizLabs did not really explain why (they just stated it was 4), I now realise that I had forgotten about the leading "null" match before the first "aaa" (even though it should have been obvious to me from my diagram.
I startes looking a bit further at this I am obviously have some serious hole in my regex knowledge (but it's late....)
Answer is 0, not 3 or 4. Why?
Answer is still 0, probably for the same reasons as above.
Answer is now 2, there seems to be a match before the first "aa", but there is no match after the last "aa". Why is that?
Answer is now 3, there's just the match before the first "aa".
Is there some crazy regex rule I should tattoo on to my frontal lobes about when it will and will not match/find nulls at the beginning/end?
I am feeling less confident about this exam with every passing day.