https://github.com/mukel/regularexpressions
Simple RegExp matching using derivatives
https://github.com/mukel/regularexpressions
Last synced: 9 months ago
JSON representation
Simple RegExp matching using derivatives
- Host: GitHub
- URL: https://github.com/mukel/regularexpressions
- Owner: mukel
- Created: 2015-07-24T02:11:01.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-07-27T14:30:36.000Z (almost 11 years ago)
- Last Synced: 2025-02-14T11:53:10.250Z (over 1 year ago)
- Language: Scala
- Size: 250 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Regular Expressions
[](https://travis-ci.org/mukel/RegularExpressions)
[](http://coveralls.io/github/mukel/RegularExpressions?branch=master)
This is a simple library to deal with regular expressions using derivatives, based on Brzozowski's 1964 paper "Derivatives of regular expressions".
## Performance Notice
This is a non-optimized implementation and is focused purely on correctness, so the raw complexity is exponential.
## Usage
It provides integration with the language, allowing the following:
```scala
val lowerCase: RE = 'a' range 'z'
val upperCase: RE = 'A' range 'Z'
val vowels: RE = "aeiou".oneOf
val digit: RE = '0' range '9'
val nonZeroDigit: RE = '1' range '9'
val unsigned: RE = "0" | (nonZeroDigit ~ digit.*)
val integer: RE = ("-" | "+").? ~ unsigned
val alphaNum = lowerCase | upperCase | digit
```
Matching is as simple as:
```scala
integer matches "1234"
email matches "foor@bar.baz"
```