Skip to content

Commit ef345ff

Browse files
committed
Documented supported syntax
1 parent 6f1b75a commit ef345ff

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,35 @@ or a huge number of possible matches, such as `/.\w/`, then only a subset of the
2323
/what about (backreferences\?) \1/.examples #=> ['what about backreferences? backreferences?']
2424
```
2525

26-
The current version is still very much under development, and contains various bugs/missing features...
27-
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!)
2855

2956
## Installation
3057

0 commit comments

Comments
 (0)