regexp-examples 0.0.1 → 0.0.2
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.
- checksums.yaml +13 -5
- data/README.md +30 -2
- data/lib/regexp-examples/groups.rb +8 -3
- data/lib/regexp-examples/version.rb +1 -1
- data/spec/regexp-examples_spec.rb +3 -1
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
M2JjOGMxOWExYWQxMzdhMjdkN2Y4YjQzMDlhMmU3Mzc2MjA3NmRhZQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NDkxOTNhYmMyZjU1YTgwMzQ5Njk5MWJmOGZjZGM1YWVhMzIxOGE3Mw==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MGVhODk0ZTI5YjU1MmIwMmVkNjdjNTZhZDIxNDU4N2MzYTA2MWM2MDJlYTBj
|
10
|
+
NDU1MGIxZmNhNGI0MTNkZjMyZjc1MDdlZGY1YThlYTg3NzUwZGNhNjcyZjg3
|
11
|
+
MjY3YWQ2Yjk2ODY0YjZmZTEyZjc2NWE0ZTY5ZWIwZmYxYWM4ZjQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NjkwYWYwM2Q1MDM3ZjEzNjc0MDU0YTU1NWRmYWQyMTljYjJhZDEzZTU0N2Jj
|
14
|
+
ODU5YmNhNTJhY2NjMWRmODJkZGE2NmM1ZjQzY2UyODU2Y2JmZDc1MGE0NTVk
|
15
|
+
NTMzYWM4NGJiNTMxMWVmZTA0MGZkZjc1NjM3ZWMxNzM5MGRiZTE=
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# regexp-examples
|
2
|
+
[](http://badge.fury.io/rb/regexp-examples)
|
2
3
|
|
3
4
|
Extends the Regexp class with the method: Regexp#examples
|
4
5
|
|
@@ -22,8 +23,35 @@ or a huge number of possible matches, such as `/.\w/`, then only a subset of the
|
|
22
23
|
/what about (backreferences\?) \1/.examples #=> ['what about backreferences? backreferences?']
|
23
24
|
```
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
## Supported syntax
|
27
|
+
|
28
|
+
* All forms of repeaters (quantifiers), e.g. `/a*/`, `/a+/`, `/a?/`, `/a{1,4}/`, `/a{3,}/`, `a{,2}`
|
29
|
+
* Boolean "Or" groups, e.g. `/a|b|c/`
|
30
|
+
* Character sets (inluding ranges and negation!), e.g. `/[abc]/`, `/[A-Z0-9]/`, `/[^a-z]/`
|
31
|
+
* Escaped characters, e.g. `/\n/`, `/\w/`, `/\D/` (and so on...)
|
32
|
+
* Capture groups, and backreferences(!!), e.g. `/(this|that) \1/`
|
33
|
+
* Arbitrarily complex combinations of all the above!
|
34
|
+
|
35
|
+
## Not-Yet-Supported syntax
|
36
|
+
|
37
|
+
I plan to add the following features to the gem (in order of most -> least likely), but have not yet got round to it:
|
38
|
+
|
39
|
+
* Non-capture groups, e.g. `/(?:foo)/`
|
40
|
+
* Named capture groups, e.g. `(?<name>bar)/`
|
41
|
+
* Throw exceptions if illegal syntax (see below) is used
|
42
|
+
* POSIX bracket expressions, e.g. `/[[:alnum:]]/`, `/[[:space:]]/`
|
43
|
+
* Options, e.g. `/pattern/i`, `/foo.*bar/m`
|
44
|
+
* Unicode characters, e.g. `/\p{L}/`, `/\p{Arabic}/`
|
45
|
+
|
46
|
+
## Impossible features ("illegal syntax")
|
47
|
+
|
48
|
+
The following features in the regex language can never be properly implemented into this gem because, put simply, they are not technically "regular"!
|
49
|
+
If you'd like to understand this in more detail, there are many good blog posts out on the internet. The [wikipedia entry](http://en.wikipedia.org/wiki/Regular_expression)'s not bad either.
|
50
|
+
|
51
|
+
* Lookarounds, e.g. `/foo(?=bar)/`, `/(?<!foo)bar/`
|
52
|
+
* Anchors, e.g. `/\bword\b/`, `/line1\n^line2/` (although a special case could perhaps be made to allow `\A`, `^`, `\z` and `$` at the beginning/end of the pattern)
|
53
|
+
|
54
|
+
(Note: Backreferences are not really "regular" either, but I got these to work with a bit of hackery!)
|
27
55
|
|
28
56
|
## Installation
|
29
57
|
|
@@ -93,13 +93,18 @@ module RegexpExamples
|
|
93
93
|
|
94
94
|
class OrGroup
|
95
95
|
def initialize(left_repeaters, right_repeaters)
|
96
|
-
@
|
96
|
+
@left_repeaters = left_repeaters
|
97
|
+
@right_repeaters = right_repeaters
|
97
98
|
end
|
98
99
|
|
99
100
|
def result
|
100
|
-
@
|
101
|
-
RegexpExamples::permutations_of_strings(repeater.result)
|
101
|
+
left_result = @left_repeaters.map do |repeater|
|
102
|
+
RegexpExamples::permutations_of_strings([repeater.result])
|
102
103
|
end
|
104
|
+
right_result = @right_repeaters.map do |repeater|
|
105
|
+
RegexpExamples::permutations_of_strings([repeater.result])
|
106
|
+
end
|
107
|
+
left_result.concat(right_result).flatten.uniq
|
103
108
|
end
|
104
109
|
end
|
105
110
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: regexp-examples
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Lord
|
@@ -14,28 +14,28 @@ dependencies:
|
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.7'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
description: Regexp#examples returns a list of strings what are matched by the regex
|
@@ -44,8 +44,8 @@ executables: []
|
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
46
46
|
files:
|
47
|
-
-
|
48
|
-
-
|
47
|
+
- .gitignore
|
48
|
+
- .rspec
|
49
49
|
- Gemfile
|
50
50
|
- LICENSE.txt
|
51
51
|
- README.md
|
@@ -72,20 +72,21 @@ require_paths:
|
|
72
72
|
- lib
|
73
73
|
required_ruby_version: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ! '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
requirements: []
|
84
84
|
rubyforge_project:
|
85
|
-
rubygems_version: 2.
|
85
|
+
rubygems_version: 2.4.2
|
86
86
|
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: Extends the Regexp class with '#examples'
|
89
89
|
test_files:
|
90
90
|
- spec/regexp-examples_spec.rb
|
91
91
|
- spec/spec_helper.rb
|
92
|
+
has_rdoc:
|