Class: MrCommon::Pattern
- Inherits:
-
Object
- Object
- MrCommon::Pattern
- Defined in:
- app/models/mr_common/pattern.rb
Overview
Common regex patterns
Class Method Summary collapse
-
.email ⇒ Object
Matches valid email addresses.
-
.phone_number ⇒ Object
Matches most phone numbers a person could enter.
Class Method Details
.email ⇒ Object
Matches valid email addresses. Ensures that the @ symbol is preceded by something resembling a username and followed by something resembling a domain name.
10 11 12 |
# File 'app/models/mr_common/pattern.rb', line 10 def email /\A\S+@\S+\.\S+\z/ end |
.phone_number ⇒ Object
Matches most phone numbers a person could enter. Tests for at least 7 of the characters that can appear in a phone number.
16 17 18 |
# File 'app/models/mr_common/pattern.rb', line 16 def phone_number /[\d()\\x+\- ]{7,}/ end |