Skip to content

Instantly share code, notes, and snippets.

@JEG2
Created March 21, 2011 19:01
Show Gist options
  • Save JEG2/879988 to your computer and use it in GitHub Desktop.
Save JEG2/879988 to your computer and use it in GitHub Desktop.
#############
### Regex ###
#############
# Build regular expressions to match each of the following:
#
# 1. An IP address. Use the format N.N.N.N, where each N is an Integer between
# 0 and 255. Don't allow numbers outside that range. There aren't always
# three digits either. For example, the loopback address for your computer
# is 127.0.0.1.
#
# 2. Write a regular expression that hunts through free form text for URL's.
# We will say a URL has to start with http://, https://, or ftp:// to count.
# Do not match a trailing ., ?, or ! for URL's at the end of a sentence,
# like this: http://blog.grayproductions.net.
#
# What do you think the following expression was built to match?
/\A\d{3}-([A-Za-z\d]-?){6}[A-Za-z\d]\z/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment