Using regular expressions in Ruby you can validate a string for a certain amount of numbers.
# The string should be a valid year after the 10th century (4 numbers)
myYear = '1986'
# Validate using RegEx
/^\d{4}$/ =~ myYear
Using regular expressions in Ruby you can validate a string for a certain amount of numbers.
# The string should be a valid year after the 10th century (4 numbers)
myYear = '1986'
# Validate using RegEx
/^\d{4}$/ =~ myYear