English subtitles

← 01-54 Phone It In Solution

Get Embed Code
5 Languages

Showing Revision 1 created 04/24/2012 by Amara Bot.

  1. Well, let's take a few stabs at it.
  2. It seems like we definitely want 0 through 9+
  3. to get the first part of any phone number.
  4. What about this regular expression?
  5. We have 0 through 9+, and then as many times as you like
  6. we have a hyphen, and then 0 through 9+ again
  7. as kind of a group.
  8. This actually works quite well.
  9. However, if we were to put a star here instead of a +,
  10. this one accepts -6 by just skipping this part
  11. and doing this part once, -6, and then we're done.
  12. We don't like this.
  13. And as we've mentioned, regular expressions admit room for creativity.
  14. What if I want to do this interesting grouping at the beginning?
  15. What if I say you can have as many of the 08-78-88- things as you want
  16. as long as you end with some final numbers?
  17. This one also works.
  18. You may remember the hyphenated word problem we had from before.
  19. This hyphenated phone number problem is actually quite similar,
  20. but now that we know how to do grouping
  21. with parentheses, it's much easier to solve.