regexp-examples 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +2 -2
- data/lib/regexp-examples/helpers.rb +2 -1
- data/lib/regexp-examples/unicode_char_ranges.rb +9 -2
- data/lib/regexp-examples/version.rb +1 -1
- metadata +2 -3
- data/db/unicode_ranges_2.1.pstore +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9894154e2704c92fcb6ca8754341277d703b32c
|
4
|
+
data.tar.gz: 3e63a6729574eac68d254315766919c5e09f4b23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17d0bb4de2e56575c782a77de333ed1c99facaa75f91d4b29ebd33b9343e37a35f337f1e75f0c62517c9b4865156bb7dd77518e3caf76077c38815dc3f638710
|
7
|
+
data.tar.gz: cf2d3b8d98116c909bd6aeb949e891f6fdfa5140fca42454a5a1c1bd24f4cb7cca6254a914b400b3776e7629281b66e688391f9e9e7536dcb298ea58fef798c2
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -188,7 +188,7 @@ There are no known major bugs with this library. However, there are a few obscur
|
|
188
188
|
* Nested repeat operators are incorrectly parsed, e.g. `/b{2}{3}/` - which *should* be interpreted like `/b{6}/`. (However, there is probably no reason
|
189
189
|
to ever write regexes like this!)
|
190
190
|
|
191
|
-
Some of the most obscure regexp features are not even mentioned in [the ruby docs](ruby-doc.org/core/Regexp.html).
|
191
|
+
Some of the most obscure regexp features are not even mentioned in [the ruby docs](http://ruby-doc.org/core/Regexp.html).
|
192
192
|
However, full documentation on all the intricate obscurities in the ruby (version 2.x) regexp parser can be found
|
193
193
|
[here](https://raw.githubusercontent.com/k-takata/Onigmo/master/doc/RE).
|
194
194
|
|
@@ -200,7 +200,7 @@ If you'd like to understand this in more detail, check out what I had to say in
|
|
200
200
|
Using any of the following will raise a `RegexpExamples::IllegalSyntax` exception:
|
201
201
|
|
202
202
|
* Lookarounds, e.g. `/foo(?=bar)/`, `/foo(?!bar)/`, `/(?<=foo)bar/`, `/(?<!foo)bar/`
|
203
|
-
* [Anchors](http://ruby-doc.org/core
|
203
|
+
* [Anchors](http://ruby-doc.org/core/Regexp.html#class-Regexp-label-Anchors) (`\b`, `\B`, `\G`, `^`, `\A`, `$`, `\z`, `\Z`), e.g. `/\bword\b/`, `/line1\n^line2/`
|
204
204
|
* Anchors are really just special cases of lookarounds!
|
205
205
|
* However, a special case has been made to allow `^`, `\A` and `\G` at the start of a pattern; and to allow `$`, `\z` and `\Z` at the end of pattern. In such cases, the characters are effectively just ignored.
|
206
206
|
* Subexpression calls (`\g`), e.g. `/(?<name> ... \g<name>* )/`
|
@@ -19,7 +19,8 @@ module RegexpExamples
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.join_preserving_capture_groups(result)
|
22
|
-
# Only save the LAST group from repeated capture groups,
|
22
|
+
# Only save the LAST group from repeated capture groups, because
|
23
|
+
# e.g. /([ab]){2} \1/.examples should NOT include "ab a"
|
23
24
|
# (Hence the need for "reverse"!)
|
24
25
|
subgroups = result
|
25
26
|
.flat_map(&:all_subgroups)
|
@@ -14,8 +14,8 @@ module RegexpExamples
|
|
14
14
|
|
15
15
|
attr_reader :range_store
|
16
16
|
|
17
|
-
def initialize
|
18
|
-
@range_store = PStore.new(
|
17
|
+
def initialize
|
18
|
+
@range_store = PStore.new(unicode_ranges_file)
|
19
19
|
end
|
20
20
|
|
21
21
|
def get(key)
|
@@ -28,6 +28,13 @@ module RegexpExamples
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
+
def unicode_ranges_file
|
32
|
+
db_path = File.join(__dir__, '../../db')
|
33
|
+
Dir["#{db_path}/*.pstore"].sort.select do |file|
|
34
|
+
file <= "#{db_path}/unicode_ranges_#{RUBY_VERSION[0..2]}.pstore"
|
35
|
+
end.last
|
36
|
+
end
|
37
|
+
|
31
38
|
# TODO: Document example input/output of this method
|
32
39
|
# It's pretty simple, but this code is a little confusing!!
|
33
40
|
def ranges_to_unicode(ranges)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: regexp-examples
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Lord
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -54,7 +54,6 @@ files:
|
|
54
54
|
- README.md
|
55
55
|
- Rakefile
|
56
56
|
- db/unicode_ranges_2.0.pstore
|
57
|
-
- db/unicode_ranges_2.1.pstore
|
58
57
|
- db/unicode_ranges_2.2.pstore
|
59
58
|
- db/unicode_ranges_2.3.pstore
|
60
59
|
- db/unicode_ranges_2.4.pstore
|
@@ -1 +0,0 @@
|
|
1
|
-
unicode_ranges_2.0.pstore
|