Skip to content

Commit

Permalink
Added support for unicode characters
Browse files Browse the repository at this point in the history
E.g. /\u0123/.examples
  • Loading branch information
tom-lord committed Jan 17, 2015
1 parent 06fc4e4 commit 76d09fb
Show file tree
Hide file tree
Showing 5 changed files with 457 additions and 328 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ or a huge number of possible matches, such as `/.\w/`, then only a subset of the
# 'http://www.github.com', 'https://github.com', 'https://www.github.com']
/(I(N(C(E(P(T(I(O(N)))))))))*/.examples #=> ["", "INCEPTION", "INCEPTIONINCEPTION"]
/\x74\x68\x69\x73/.examples #=> ["this"]
/\u6829/.examples #=> ["栩"]
/what about (backreferences\?) \1/.examples #=> ['what about backreferences? backreferences?']
```

Expand All @@ -39,6 +40,7 @@ or a huge number of possible matches, such as `/.\w/`, then only a subset of the
* Groups work fine, even if nested! e.g. `/(even(this(works?))) \1 \2 \3/`
* Control characters, e.g. `/\ca/`, `/\cZ/`, `/\C-9/`
* Escape sequences, e.g. `/\x42/`, `/\x3D/`, `/\5word/`, `/#{"\x80".force_encoding("ASCII-8BIT")}/`
* Unicode characters, e.g. `/\u0123/`, `/\uabcd/`
* **Arbitrarily complex combinations of all the above!**

## Not-Yet-Supported syntax
Expand All @@ -48,7 +50,6 @@ I plan to add the following features to the gem, but have not yet got round to i
* Throw exceptions if illegal syntax (see below) is used. This is currently only partially implemented (for lookarounds only).
* POSIX bracket expressions, e.g. `/[[:alnum:]]/`, `/[[:space:]]/`
* Options, e.g. `/pattern/i`, `/foo.*bar/m`
* Unicode characters, e.g. `/\u06E9/`
* Named properties, e.g. `/\p{L}/` ("Letter"), `/\p{Arabic}/` ("Arabic character"), `/\p{^Ll}/` ("Not a lowercase letter")
* Subexpression calls, e.g. `/(?<name> ... \g<name>* )/` (Note: These could get _really_ ugly to implement, and may even be impossible, so I highly doubt it's worth the effort!)

Expand Down
128 changes: 72 additions & 56 deletions coverage/.resultset.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
null,
null,
1,
288,
288,
290,
290,
168,
241,
null,
Expand All @@ -38,28 +38,28 @@
1,
1,
1,
288,
290,
null,
null,
1,
288,
288,
288,
318,
432,
290,
290,
290,
320,
434,
null,
null,
288,
290,
null,
null,
null,
1,
1,
263,
265,
null,
null,
1,
263,
265,
null,
null,
null,
Expand Down Expand Up @@ -117,11 +117,11 @@
1,
1,
1,
67,
163,
69,
165,
28,
null,
163,
165,
null,
null,
null,
Expand Down Expand Up @@ -192,28 +192,28 @@
1,
1,
1,
71,
71,
71,
73,
73,
73,
null,
null,
1,
118,
118,
333,
329,
288,
288,
288,
120,
120,
335,
331,
290,
290,
290,
null,
114,
116,
null,
null,
1,
null,
1,
333,
333,
335,
335,
null,
45,
null,
Expand All @@ -225,15 +225,15 @@
null,
6,
null,
47,
49,
null,
179,
null,
329,
331,
null,
null,
1,
47,
49,
null,
null,
19,
Expand All @@ -253,14 +253,17 @@
3,
null,
2,
2,
null,
2,
null,
47,
47,
49,
49,
null,
null,
1,
288,
288,
290,
290,
null,
5,
null,
Expand All @@ -270,9 +273,9 @@
null,
5,
null,
263,
265,
null,
288,
290,
null,
null,
1,
Expand Down Expand Up @@ -336,7 +339,7 @@
null,
null,
1,
192,
194,
null,
null,
1,
Expand All @@ -353,6 +356,10 @@
null,
null,
1,
2,
null,
null,
1,
5,
5,
null,
Expand All @@ -377,11 +384,11 @@
null,
null,
1,
263,
265,
null,
null,
1,
143,
155,
null,
null,
null,
Expand All @@ -395,12 +402,12 @@
1,
1,
1,
1673,
1673,
1673,
1677,
1677,
1677,
122,
null,
1673,
1677,
null,
null,
1,
Expand All @@ -410,16 +417,16 @@
null,
null,
1,
432,
434,
null,
null,
null,
1,
1,
192,
194,
null,
1,
192,
194,
null,
null,
null,
Expand Down Expand Up @@ -538,12 +545,12 @@
1,
1,
1,
71,
73,
null,
null,
131,
67,
67,
133,
69,
69,
null,
null,
1,
Expand All @@ -553,11 +560,11 @@
"/home/tom/git/regexp-examples/spec/regexp-examples_spec.rb": [
1,
1,
9,
67,
67,
67,
230,
10,
69,
69,
69,
234,
null,
null,
null,
Expand Down Expand Up @@ -696,9 +703,18 @@
null,
null,
null,
null,
1,
1,
null,
null,
null,
null,
null,
null,
null
]
},
"timestamp": 1421511606
"timestamp": 1421512650
}
}
Loading

0 comments on commit 76d09fb

Please sign in to comment.