# utils-regex-from-string

> Parses a regular expression string and returns a new regular expression.

Latest version **1.0.0** (published 2015-08-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install utils-regex-from-string
pnpm add utils-regex-from-string
yarn add utils-regex-from-string
bun add utils-regex-from-string
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-08-26 |
| First published | 2015-08-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Athan Reines |
| Maintainers | kgryte |
| Keywords | util, utils, utility, utilities, regular, expression, regex, regexp, string |

## Links

- npm: https://www.npmjs.com/package/utils-regex-from-string
- Repository: https://github.com/kgryte/utils-regex-from-string
- Homepage: https://github.com/kgryte/utils-regex-from-string#readme
- Issues: https://github.com/kgryte/utils-regex-from-string/issues
- npm.io page: https://npm.io/package/utils-regex-from-string

## Dependencies (2)

- [regex-regex](https://npm.io/package/regex-regex.md) ^1.0.0
- [validate.io-string-primitive](https://npm.io/package/validate.io-string-primitive.md) ^1.0.0

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2015-08-26
- 0.0.0 — 2015-08-26

## README

RegExp
===
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependencies][dependencies-image]][dependencies-url]

> Parses a [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) string and returns a new [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions).


## Installation

``` bash
$ npm install utils-regex-from-string
```


## Usage

``` javascript
var regex = require( 'utils-regex-from-string' );
```

#### regex( str )

Parses a [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) `string` and returns a new [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions).

``` javascript
var re = regex( '/beep/' )
// returns /beep/
```

__Note__: provided `strings` must be properly __escaped__.

``` javascript
// Unescaped:
re = regex( '/\w+/' );
// returns /w+/

// Escaped:
re = regex( '/\\w+/' );
// returns /\w+/
```


## Examples

``` javascript
var regex = require( 'utils-regex-from-string' );

console.log( regex( '/beep/' ) );
// returns /beep/

console.log( regex( '/[A-Z]*/' ) );
// returns /[A-Z]*/

console.log( regex( '/\\\\\\\//ig' ) );
// returns /\\\//ig

console.log( regex( '/[A-Z]{0,}/' ) );
// returns /[A-Z]{0,}/

console.log( regex( '/^boop$/' ) );
// returns /^boop$/

console.log( regex( '/(?:.*)/' ) );
// returns /(?:.*)/

console.log( regex( '/(?:beep|boop)/' ) );
// returns /(?:beep|boop)/

console.log( regex( '/\\w+/' ) );
// returns /\w+/
```

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 &copy; 2015. Athan Reines.


[npm-image]: http://img.shields.io/npm/v/utils-regex-from-string.svg
[npm-url]: https://npmjs.org/package/utils-regex-from-string

[travis-image]: http://img.shields.io/travis/kgryte/utils-regex-from-string/master.svg
[travis-url]: https://travis-ci.org/kgryte/utils-regex-from-string

[codecov-image]: https://img.shields.io/codecov/c/github/kgryte/utils-regex-from-string/master.svg
[codecov-url]: https://codecov.io/github/kgryte/utils-regex-from-string?branch=master

[dependencies-image]: http://img.shields.io/david/kgryte/utils-regex-from-string.svg
[dependencies-url]: https://david-dm.org/kgryte/utils-regex-from-string

[dev-dependencies-image]: http://img.shields.io/david/dev/kgryte/utils-regex-from-string.svg
[dev-dependencies-url]: https://david-dm.org/dev/kgryte/utils-regex-from-string

[github-issues-image]: http://img.shields.io/github/issues/kgryte/utils-regex-from-string.svg
[github-issues-url]: https://github.com/kgryte/utils-regex-from-string/issues

---
_Source: https://npm.io/package/utils-regex-from-string · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
