English subtitles

← 07-03 Regexps Solution

Get Embed Code
3 Languages

Showing Revision 1 created 06/29/2012 by Amara Bot.

  1. We see that this regular expression starts with an unmodified "a".
  2. So we can rule out immediately any of these strings at the bottom that start with a "b".
  3. They're not going to match it. The first letter has to be an "a".
  4. So we have an "a," and then remember that open parenthesis, question mark, colon,
  5. and close parenthesis are a Python syntax loosely just meaning open and close parentheses.
  6. So we've got an "a" followed by zero or more copies of "a? b*".
  7. "B*" can be no b's, and this " * " can be once,
  8. so this could be "a?" or just "aa," so yeah, we can match that.
  9. How about this, "aab"? Same strategy as before except that we make this "b*" be one "b".
  10. We can match this "abab"--"a", "b." We'll take one of these and then we'll repeat this whole group once.
  11. This time, we'll take the "a" that we really want and one more "b". Yeah, we can match this.
  12. "Abbabb", "a". We'll skip over this optional "a?". We will have this "*" be twice.
  13. We'll repeat the whole thing. We'll include the optional "a?".
  14. We will have this "*" be twice and now we're done. Yeah, we can match that.
  15. And then finally here, just like the previous string, but we want one more "a" at the end.
  16. Well, we'll take the outermost loop one more time. Take this. Not take the star.