|
1 |
| -# quoted-string-regex [](http://badge.fury.io/js/quoted-string-regex) [](https://travis-ci.org/regexps/quoted-string-regex) |
| 1 | +# quoted-string-regex [](https://www.npmjs.com/package/quoted-string-regex) [](https://npmjs.org/package/quoted-string-regex) [](https://npmjs.org/package/quoted-string-regex) [](https://travis-ci.org/regexps/quoted-string-regex) |
2 | 2 |
|
3 | 3 | > JavaScript regular expression for matching a quoted string.
|
4 | 4 |
|
5 |
| -Originally [posted here](https://github.com/less/less.js/issues/2339#issuecomment-67211009). |
| 5 | +Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support. |
6 | 6 |
|
7 | 7 | ## Install
|
8 | 8 |
|
9 |
| -Install with [npm](https://www.npmjs.com/) |
| 9 | +Install with [npm](https://www.npmjs.com/): |
10 | 10 |
|
11 | 11 | ```sh
|
12 |
| -$ npm i quoted-string-regex --save |
| 12 | +$ npm install --save quoted-string-regex |
13 | 13 | ```
|
14 | 14 |
|
15 | 15 | ## Usage
|
16 | 16 |
|
17 | 17 | ```js
|
18 | 18 | var regex = require('quoted-string-regex');
|
19 |
| -('var foo = \'bar\';').match(regex()); |
| 19 | +console.log(regex().exec('var foo = \'bar\';')[2]); |
20 | 20 | //=> ['bar']
|
21 | 21 |
|
22 |
| -('var foo = "bar";').match(regex()); |
23 |
| -//=> ['"bar"''] |
| 22 | +console.log(regex().exec('var foo = "bar";')[2]); |
| 23 | +//=> ['bar'] |
| 24 | + |
| 25 | +console.log(regex().exec('var foo = "bar";\nvar bar = \'baz\'')[2]); |
| 26 | +//=> ['bar'] |
24 | 27 |
|
25 |
| -('var foo = "bar";\nvar bar = \'baz\'').match(regex()); |
26 |
| -//=> ['"bar"', '\'baz\''] |
| 28 | +console.log('var foo = "one";\nvar bar = \'two\';\nvar baz = `three`'.match(regex())); |
| 29 | +//=> [ '"one"', '\'two\'', '`three`' ] |
27 | 30 |
|
28 |
| -('foo bar ". // \' \\ . // \' \\ ." baz').match(regex()); |
29 |
| -//=> ['". // \' \\ . // \' \\ ."'] |
| 31 | +console.log(regex().exec('foo bar ". // \' \\ . // \' \\ ." baz')[2]); |
| 32 | +//=> ['. // \' \\ . // \' \\ .'] |
30 | 33 | ```
|
31 | 34 |
|
32 |
| -## Related projects |
| 35 | +## About |
| 36 | + |
| 37 | +<details> |
| 38 | +<summary><strong>Contributing</strong></summary> |
33 | 39 |
|
34 |
| -* [copyright-regex](https://www.npmjs.com/package/copyright-regex): Regex for matching and parsing copyright statements. | [homepage](https://github.com/regexps/copyright-regex) |
35 |
| -* [todo-regex](https://www.npmjs.com/package/todo-regex): Regular expression for matching TODO statements in a string. | [homepage](https://github.com/regexps/todo-regex) |
| 40 | +Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). |
36 | 41 |
|
37 |
| -## Running tests |
| 42 | +</details> |
38 | 43 |
|
39 |
| -Install dev dependencies: |
| 44 | +<details> |
| 45 | +<summary><strong>Running Tests</strong></summary> |
| 46 | + |
| 47 | +Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: |
40 | 48 |
|
41 | 49 | ```sh
|
42 |
| -$ npm i -d && npm test |
| 50 | +$ npm install && npm test |
43 | 51 | ```
|
44 | 52 |
|
45 |
| -## Contributing |
| 53 | +</details> |
| 54 | +<details> |
| 55 | +<summary><strong>Building docs</strong></summary> |
| 56 | + |
| 57 | +_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ |
| 58 | + |
| 59 | +To generate the readme, run the following command: |
| 60 | + |
| 61 | +```sh |
| 62 | +$ npm install -g verbose/verb#dev verb-generate-readme && verb |
| 63 | +``` |
| 64 | + |
| 65 | +</details> |
| 66 | + |
| 67 | +### Related projects |
| 68 | + |
| 69 | +You might also be interested in these projects: |
46 | 70 |
|
47 |
| -Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/regexps/quoted-string-regex/issues/new). |
| 71 | +* [es6-template-regex](https://www.npmjs.com/package/es6-template-regex): Regular expression for matching es6 template delimiters in a string. | [homepage](https://github.com/regexhq/es6-template-regex "Regular expression for matching es6 template delimiters in a string.") |
| 72 | +* [to-regex-range](https://www.npmjs.com/package/to-regex-range): Pass two numbers, get a regex-compatible source string for matching ranges. Validated against more than… [more](https://github.com/micromatch/to-regex-range) | [homepage](https://github.com/micromatch/to-regex-range "Pass two numbers, get a regex-compatible source string for matching ranges. Validated against more than 2.78 million test assertions.") |
| 73 | +* [year-range-regex](https://www.npmjs.com/package/year-range-regex): Generates a regular expression for validating a range of years. | [homepage](https://github.com/jonschlinkert/year-range-regex "Generates a regular expression for validating a range of years.") |
48 | 74 |
|
49 |
| -## Author |
| 75 | +### Author |
50 | 76 |
|
51 | 77 | **Jon Schlinkert**
|
52 | 78 |
|
53 |
| -+ [github/jonschlinkert](https://github.com/jonschlinkert) |
54 |
| -+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) |
| 79 | +* [linkedin/in/jonschlinkert](https://linkedin.com/in/jonschlinkert) |
| 80 | +* [github/jonschlinkert](https://github.com/jonschlinkert) |
| 81 | +* [twitter/jonschlinkert](https://twitter.com/jonschlinkert) |
55 | 82 |
|
56 |
| -## License |
| 83 | +### License |
57 | 84 |
|
58 |
| -Copyright © 2015 Jon Schlinkert |
59 |
| -Released under the MIT license. |
| 85 | +Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert). |
| 86 | +Released under the [MIT License](LICENSE). |
60 | 87 |
|
61 | 88 | ***
|
62 | 89 |
|
63 |
| -_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on November 02, 2015._ |
| 90 | +_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on January 15, 2018._ |
0 commit comments