Using Regular Expressions to validate a fixed length numerical string.
a = '547' /^\d\d\d$/ ~= a
DZone Snippets > jrobertson > numeric
11304 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
James Robertson http://www.r0bertson.co.uk
a = '547' /^\d\d\d$/ ~= a
a = '134323' /^[0-9]*$/ =~ a #result returns 0, indicating success