Skip to content

Instantly share code, notes, and snippets.

@stomatocode
Created May 6, 2013 06:27
Show Gist options
  • Save stomatocode/5523629 to your computer and use it in GitHub Desktop.
Save stomatocode/5523629 to your computer and use it in GitHub Desktop.
def has_ssn?(string)
if string =~ /\d{3}\W\d{2}\W\d{4}/
true
elsif string =~ /\d{9}/
true
else
false
end
end
# Return the Social Security number from a string.
def grab_ssn(string)
if string.match(/\d{3}\W\d{2}\W\d{4}/)
puts "#{string.match(/\d{3}\W\d{2}\W\d{4}/)}"
elsif string.match(/\d{9}/)
puts "#{string.match(/\d{9}/)}"
else
nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment