Module: BbsUploader::RubyRegex

Defined in:
lib/bbs_uploader/ruby_regex.rb

Constant Summary collapse

Username =

Username This regular expression doesn’t validate username’s length

/\A[a-zA-Z0-9_]*\z/
Dni =

Dni (spanish ID card)

/\A\d{8}[A-Za-z]{1}\z/
Url =

URL

URL = /(\A\z)|(\A(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?\z)/ix
Domain =

Domain

/(\A\z)|(\A[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?)?\z)/ix
CreditCard =

CreditCard Validates Credit Card numbers, Checks if it contains 16 numbers in groups of 4 separated by -, space or nothing

/\A(\d{4}-){3}\d{4}\z|\A(\d{4}\s){3}\d{4}\z|\A\d{16}\z/
MasterCard =

MasterCard credit card

/\A5[1-5]\d{14}\z/
Visa =

Visa credit card

/\A4\d{15}\z/
USSocialSecurity =

US Social Security

/\A\d{3}-\d{2}-\d{4}\z/
GeneralPostalCode =

General postal code Validates a 5 digits postal code

/\A\d{5}\z/
ZIPCode =

US ZIP code Validates US ZIP Code (basic and extended format)

/\A(\d{5}\z)|(\d{5}-\d{4}\z)/
TwitterUsername =

Twitter username

/\A([a-z0-9\_])+\z/ix
GithubUsername =

Github username

/\A([a-z0-9\_\-])+\z/ix
SlideshareUsername =

Slideshare username

/\A([a-z0-9])+\z/ix
DeliciousUsername =

Del.icio.us username

/\A([a-z0-9\_\-])+\z/ix
Email =

Email From the email regex research: fightingforalostcause.net/misc/2006/compare-email-regex.php Authors: James Watts and Francisco Jose Martin Moreno

/\A([\w\!\#\z\%\&\'\*\+\-\/\=\?\\A\`{\|\}\~]+\.)*[\w\+-]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)\z/i
UUID =

UUID Validates a UUID as defined: en.wikipedia.org/wiki/Universally_unique_identifier

/\A([0-9a-fA-F]{32}|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})\z/
DBDate =

Date DB format YYYY-MM-DD I know it will validate 2001-02-31 but is I think we are focusing in formats more than in parsing

/\A\d{4}-(#{("01".."12").to_a.join("|")})-(#{("01".."31").to_a.join("|")})\z/
DBDateTime =

Date Time DB format YYYY-MM-DD hh:mm:ss

/\A\d{4}-(#{("01".."12").to_a.join("|")})-(#{("01".."31").to_a.join("|")})\s(#{("00".."23").to_a.join("|")}):(#{("00".."59").to_a.join("|")}):(#{("00".."59").to_a.join("|")})\z/
SpanishBankAccountNumber =

SpanishBankAccountNumber

/\A\d{4}[ -]?\d{4}[ -]?\d{2}[ -]?\d{10}\z/
IBAN =

IBAN Source: snipplr.com/view/15322/iban-regex-all-ibans/ You have to remove spaces or any separator character from the original field before use this regex

/[a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{4}[0-9]{7}([a-zA-Z0-9]?){0,16}/
MacAddress =

MacAddress

/\A([0-9A-F]{2}[:-]){5}([0-9A-F]{2})\z/i