regexp-examples 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 90a3c94b7ce9d60074ab46c196d6fab9cc19552c
4
- data.tar.gz: 75f7bff2b43831f82dc0c5250a59adab1c993084
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ M2JjOGMxOWExYWQxMzdhMjdkN2Y4YjQzMDlhMmU3Mzc2MjA3NmRhZQ==
5
+ data.tar.gz: !binary |-
6
+ NDkxOTNhYmMyZjU1YTgwMzQ5Njk5MWJmOGZjZGM1YWVhMzIxOGE3Mw==
5
7
  SHA512:
6
- metadata.gz: 1a4eba9d6f17c34a9f482a4bf73bed58f2541dc5233c6582ac683053fba3b23b21a8672ad0dda631ad38562870e17aa5293e828f121e46b2c1408d893ba50756
7
- data.tar.gz: 2de1f70fe0299072a07a60d86e549a3c71ba3f3ce31572e4e9df37acb7bb8e69a7f72ce2b568a95c2647bc1b47fa914605a41f3105c25ddc7131841e5751c916
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
+ [![Gem Version](https://badge.fury.io/rb/regexp-examples.svg)](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
- The current version is still very much under development, and contains various bugs/missing features...
26
- However, when completed, this will hopefully work for ALL regular expressions, *except for lookarounds*!
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
- @repeaters = left_repeaters.concat(right_repeaters)
96
+ @left_repeaters = left_repeaters
97
+ @right_repeaters = right_repeaters
97
98
  end
98
99
 
99
100
  def result
100
- @repeaters.map do |repeater|
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
 
@@ -1,3 +1,3 @@
1
1
  module RegexpExamples
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -82,7 +82,9 @@ describe Regexp, "#examples" do
82
82
  /(I(N(C(E(P(T(I(O(N)))))))))*/,
83
83
  /[\w]{1}/,
84
84
  /((a?b*c+)) \1/,
85
- /((a?b*c+)?) \1/
85
+ /((a?b*c+)?) \1/,
86
+ /a|b|c|d/,
87
+ /a+|b*|c?/
86
88
  )
87
89
  end
88
90
  end
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.1
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
- - ".gitignore"
48
- - ".rspec"
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.2.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: