Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kgryte/regex-regex
Regular expression to parse a regular expression string.
https://github.com/kgryte/regex-regex
Last synced: 25 days ago
JSON representation
Regular expression to parse a regular expression string.
- Host: GitHub
- URL: https://github.com/kgryte/regex-regex
- Owner: kgryte
- License: mit
- Created: 2015-08-25T06:15:37.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-25T08:05:45.000Z (about 9 years ago)
- Last Synced: 2024-10-05T11:06:19.813Z (about 1 month ago)
- Language: Makefile
- Size: 125 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
RegExp String
===
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependencies][dependencies-image]][dependencies-url]> [Regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) to parse a [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) string.
## Installation
``` bash
$ npm install regex-regex
```## Usage
``` javascript
var re = require( 'regex-regex' );
```#### re
[Regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) to parse a [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) string.
``` javascript
var bool = re.test( '/^beep$/' );
// returns truebool = re.test( '' );
// returns false
```[Regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) strings should be escaped.
``` javascript
bool = re.test( '/^\/([^\/]+)\/(.*)$/' );
// returns falsebool = re.test( '/^\\/([^\\/]+)\\/(.*)$/' );
// returns true
```## Examples
``` javascript
var re = require( 'regex-regex' );console.log( re.test( '/beep/' ) );
// returns trueconsole.log( re.test( '/^.*$/ig' ) );
// returns trueconsole.log( re.test( '/^\\/([^\\/]+)\\/(.*)$/' ) );
// returns trueconsole.log( re.test( '/^\/([^\/]+)\/(.*)$/' ) );
// returns falseconsole.log( re.test( '/boop' ) );
// returns falseconsole.log( re.test( '' ) );
// returns false
```To run the example code from the top-level application directory,
``` bash
$ node ./examples/index.js
```## Tests
### Unit
Unit tests use the [Mocha](http://mochajs.org/) test framework with [Chai](http://chaijs.com) assertions. To run the tests, execute the following command in the top-level application directory:
``` bash
$ make test
```All new feature development should have corresponding unit tests to validate correct functionality.
### Test Coverage
This repository uses [Istanbul](https://github.com/gotwarlost/istanbul) as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
``` bash
$ make test-cov
```Istanbul creates a `./reports/coverage` directory. To access an HTML version of the report,
``` bash
$ make view-cov
```---
## License[MIT license](http://opensource.org/licenses/MIT).
## Copyright
Copyright © 2015. Athan Reines.
[npm-image]: http://img.shields.io/npm/v/regex-regex.svg
[npm-url]: https://npmjs.org/package/regex-regex[travis-image]: http://img.shields.io/travis/kgryte/regex-regex/master.svg
[travis-url]: https://travis-ci.org/kgryte/regex-regex[codecov-image]: https://img.shields.io/codecov/c/github/kgryte/regex-regex/master.svg
[codecov-url]: https://codecov.io/github/kgryte/regex-regex?branch=master[dependencies-image]: http://img.shields.io/david/kgryte/regex-regex.svg
[dependencies-url]: https://david-dm.org/kgryte/regex-regex[dev-dependencies-image]: http://img.shields.io/david/dev/kgryte/regex-regex.svg
[dev-dependencies-url]: https://david-dm.org/dev/kgryte/regex-regex[github-issues-image]: http://img.shields.io/github/issues/kgryte/regex-regex.svg
[github-issues-url]: https://github.com/kgryte/regex-regex/issues