ruby_regex 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/CHANGELOG +5 -0
  2. data/README.rdoc +1 -0
  3. data/lib/ruby_regex.rb +32 -32
  4. metadata +2 -2
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ 30/09/2011
2
+ -------------------------
3
+ Regular expressions match with \A and \z (string delimiters)
4
+ instead of ^ and $ (line delimiters)
5
+
1
6
  27/09/2011
2
7
  -------------------------
3
8
  Add UUID regexp
data/README.rdoc CHANGED
@@ -41,6 +41,7 @@ If you want to contribute send me a pull request with new regular expressions (a
41
41
  - Jaime Iniesta
42
42
  - Fernando Guillen
43
43
  - Christopher Klapp
44
+ - Guillermo Alvarez
44
45
 
45
46
  ---
46
47
 
data/lib/ruby_regex.rb CHANGED
@@ -1,56 +1,56 @@
1
1
  module RubyRegex
2
2
  # Username
3
3
  # This regular expression doesn't validate username's length
4
- Username = /^[a-zA-Z0-9_]*$/
5
-
4
+ Username = /\A[a-zA-Z0-9_]*\z/
5
+
6
6
  # Dni (spanish ID card)
7
- Dni = /^\d{8}[A-Za-z]{1}$/
8
-
7
+ Dni = /\A\d{8}[A-Za-z]{1}\z/
8
+
9
9
  # URL
10
- Url = URL = /(^$)|(^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$)/ix
11
-
10
+ Url = URL = /(\A\z)|(\A(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?\z)/ix
11
+
12
12
  # Domain
13
- Domain = /(^$)|(^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?)?$)/ix
14
-
13
+ Domain = /(\A\z)|(\A[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?)?\z)/ix
14
+
15
15
  # CreditCard
16
16
  # Validates Credit Card numbers, Checks if it contains 16 numbers in groups of 4 separated by -, space or nothing
17
- CreditCard = /^(\d{4}-){3}\d{4}$|^(\d{4}\s){3}\d{4}$|^\d{16}$/
18
-
17
+ CreditCard = /\A(\d{4}-){3}\d{4}\z|\A(\d{4}\s){3}\d{4}\z|\A\d{16}\z/
18
+
19
19
  # MasterCard credit card
20
- MasterCard = /^5[1-5]\d{14}$/
21
-
20
+ MasterCard = /\A5[1-5]\d{14}\z/
21
+
22
22
  # Visa credit card
23
- Visa = /^4\d{15}$/
24
-
23
+ Visa = /\A4\d{15}\z/
24
+
25
25
  # US Social Security
26
- USSocialSecurity = /^\d{3}-\d{2}-\d{4}$/
27
-
26
+ USSocialSecurity = /\A\d{3}-\d{2}-\d{4}\z/
27
+
28
28
  # General postal code
29
29
  # Validates a 5 digits postal code
30
- GeneralPostalCode = /^\d{5}$/
31
-
30
+ GeneralPostalCode = /\A\d{5}\z/
31
+
32
32
  # US ZIP code
33
33
  # Validates US ZIP Code (basic and extended format)
34
- ZIPCode = /^(\d{5}$)|(\d{5}-\d{4}$)/
35
-
34
+ ZIPCode = /\A(\d{5}\z)|(\d{5}-\d{4}\z)/
35
+
36
36
  # Twitter username
37
- TwitterUsername = /^([a-z0-9\_])+$/ix
38
-
37
+ TwitterUsername = /\A([a-z0-9\_])+\z/ix
38
+
39
39
  # Github username
40
- GithubUsername = /^([a-z0-9\_\-])+$/ix
41
-
40
+ GithubUsername = /\A([a-z0-9\_\-])+\z/ix
41
+
42
42
  # Slideshare username
43
- SlideshareUsername = /^([a-z0-9])+$/ix
44
-
43
+ SlideshareUsername = /\A([a-z0-9])+\z/ix
44
+
45
45
  # Del.icio.us username
46
- DeliciousUsername = /^([a-z0-9\_\-])+$/ix
47
-
46
+ DeliciousUsername = /\A([a-z0-9\_\-])+\z/ix
47
+
48
48
  # Email
49
49
  # From the email regex research: http://fightingforalostcause.net/misc/2006/compare-email-regex.php
50
50
  # Authors: James Watts and Francisco Jose Martin Moreno
51
- Email = /^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\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})?)$/i
52
-
51
+ Email = /\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
52
+
53
53
  # UUID
54
54
  # Validates a UUID as defined: http://en.wikipedia.org/wiki/Universally_unique_identifier
55
- UUID = /^(\h{32}|\h{8}-\h{4}-\h{4}-\h{4}-\h{12})$/
56
- end
55
+ UUID = /\A(\h{32}|\h{8}-\h{4}-\h{4}-\h{4}-\h{12})\z/
56
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_regex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-27 00:00:00.000000000Z
12
+ date: 2011-09-30 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: Ruby regular expressions library
15
15
  email: emili@eparreno.com