Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/espadrine/reglist
Compile a list of regexes to a single regex.
https://github.com/espadrine/reglist
Last synced: 10 days ago
JSON representation
Compile a list of regexes to a single regex.
- Host: GitHub
- URL: https://github.com/espadrine/reglist
- Owner: espadrine
- License: mit
- Created: 2015-06-07T08:06:46.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-24T16:02:11.000Z (about 9 years ago)
- Last Synced: 2024-08-09T03:06:57.852Z (3 months ago)
- Language: JavaScript
- Size: 141 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Reglist, a Regular Expression List Compiler.
Take a list of regexes and make a single regex. Gives you which regex matched
and its matching groups.```js
var Reglist = require('reglist')
var reglist = new Reglist()
reglist.add([
/[^\-]*-([^\-])/,
/data:([a-z\/]+)(?:;base64|;binary),.+/,
])
var matched = reglist.match("data:text/plain;base64,aDfwkTPmx98==")
// { index: 1,
// match: [ 'data:text/plain;base64,aDfwkTPmx98==', 'text/plain' ] }
```## Speed
This is meant to be faster than executing the whole list of regexes in a loop.
I have no idea whether it is actually faster. Science has yet to come.