UNPKG

6.89 kBMarkdownView Raw
1<!-- Please do not edit this file. Edit the `blah` field in the `package.json` instead. If in doubt, open an issue. -->
2
3
4# regex-escape
5
6 [![Support me on Patreon][badge_patreon]][patreon] [![Buy me a book][badge_amazon]][amazon] [![PayPal][badge_paypal_donate]][paypal-donations] [![Ask me anything](https://img.shields.io/badge/ask%20me-anything-1abc9c.svg)](https://github.com/IonicaBizau/ama) [![Version](https://img.shields.io/npm/v/regex-escape.svg)](https://www.npmjs.com/package/regex-escape) [![Downloads](https://img.shields.io/npm/dt/regex-escape.svg)](https://www.npmjs.com/package/regex-escape) [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github)
7
8<a href="https://www.buymeacoffee.com/H96WwChMy" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png" alt="Buy Me A Coffee"></a>
9
10> Escapes input characters to be used in regular expressions.
11
12## :cloud: Installation
13
14```sh
15# Using npm
16npm install --save regex-escape
17
18# Using yarn
19yarn add regex-escape
20```
21
22
23## :clipboard: Example
24
25
26
27```js
28// Dependencies
29var RegexEscape = require("regex-escape");
30
31console.log(RegexEscape("{#/}"));
32// => \{#\/\}
33```
34
35
36
37## :question: Get Help
38
39There are few ways to get help:
40
41 1. Please [post questions on Stack Overflow](https://stackoverflow.com/questions/ask). You can open issues with questions, as long you add a link to your Stack Overflow question.
42 2. For bug reports and feature requests, open issues. :bug:
43
44 3. For direct and quick help, you can [use Codementor](https://www.codementor.io/johnnyb). :rocket:
45
46
47
48## :memo: Documentation
49
50
51### `RegexEscape(input)`
52Escapes a string for using it in a regular expression.
53
54#### Params
55
56- **String** `input`: The string that must be escaped.
57
58#### Return
59- **String** The escaped string.
60
61### `proto()`
62Adds the `RegexEscape` function to `RegExp` class.
63
64#### Return
65- **Function** The `RegexEscape` function.
66
67
68
69## :yum: How to contribute
70Have an idea? Found a bug? See [how to contribute][contributing].
71
72
73## :sparkling_heart: Support my projects
74
75I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously,
76this takes time. You can integrate and use these projects in your applications *for free*! You can even change the source code and redistribute (even resell it).
77
78However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:
79
80
81 - Starring and sharing the projects you like :rocket:
82 - [![Buy me a book][badge_amazon]][amazon]—I love books! I will remember you after years if you buy me one. :grin: :book:
83 - [![PayPal][badge_paypal]][paypal-donations]—You can make one-time donations via PayPal. I'll probably buy a ~~coffee~~ tea. :tea:
84 - [![Support me on Patreon][badge_patreon]][patreon]—Set up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).
85 - **Bitcoin**—You can send me bitcoins at this address (or scanning the code below): `1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6`
86
87 ![](https://i.imgur.com/z6OQI95.png)
88
89
90Thanks! :heart:
91
92
93## :cake: Thanks
94Big thanks to [CoolAj86](http://stackoverflow.com/users/151312/coolaj86) for posting [this answer](http://stackoverflow.com/a/6969486/1420197). This library uses the black magic regex from that answer. :sparkles:
95
96## :dizzy: Where is this library used?
97If you are using this library in one of your projects, add it in this list. :sparkles:
98
99
100 - [`barbe`](https://github.com/IonicaBizau/barbe)—Like mustache, but simple, tiny and fast.
101 - [`bloggify-router`](https://github.com/Bloggify/default-router#readme) (by Bloggify)—The default Bloggify router.
102 - [`camelo`](https://github.com/IonicaBizau/camelo#readme)—Convert a string into camel case style by providing the separators.
103 - [`chance-token-replacer`](https://github.com/drewbrokke/chance-token-replacer#readme) (by Drew Brokke)—A simple utility to replace tokens in a string with generations from the chance random generator helper
104 - [`css-assets`](https://github.com/manojchandrashekar/css-assets#readme) (by Manoj Chandrashekar)—Helps build CSS files and referenced assets.
105 - [`doodle-data`](https://github.com/regular/doodle-data#readme) (by Jan Bölsche)—get the data of a doodle.com poll
106 - [`emoji.css`](https://github.com/IonicaBizau/emoji.css)—Your website. Emojified. Like FontAwesome for emojis.
107 - [`engine-flow-types`](https://github.com/jillix/engine-flow-types#readme) (by jillix)—Low level library providing Engine flow types.
108 - [`gatsby-plugin-compile-es6-packages`](https://github.com/robwalkerco/gatsby-plugin-compile-es6-packages#readme) (by Rob Walker)—Easily add support for compiling ES6 packages into Gasby projects
109 - [`html-encoder-decoder`](https://github.com/IonicaBizau/html-encoder-decoder)—HTML Encoder / Decoder - Converts characters to their corresponding HTML Entities
110 - [`hubot-lgtm`](https://github.com/catops/hubot-lgtm#readme) (by Chris Contolini)—Automatically merge pull requests after contributors have given the thumbs up
111 - [`items-service`](https://github.com/BlueForestTrees/items-service#readme)—Les services commun de gestion d'items dans blueforest
112 - [`kresus`](https://npmjs.com/package/kresus)—Kresus' Personal Finance Manager
113 - [`luhnify`](https://github.com/koopero/luhnify#readme) (by Samm Cooper)—Generate random Luhn sequences, such as credit card numbers.
114 - [`parse-it`](https://github.com/IonicaBizau/parse-it#readme)—Configurable string templating, without separators.
115 - [`slugly`](https://github.com/IonicaBizau/slugly#readme)—A minimal and yet powerful slug library.
116 - [`taskcluster-lib-references`](https://github.com/taskcluster/taskcluster-lib-references#readme) (by Dustin J. Mitchell)—Taskcluster-lib-references is responsible for handling the API reference data, including manifests, API references, exchange references, and JSON schemas.
117
118## :scroll: License
119
120[MIT][license] © [Ionică Bizău][website]
121
122
123[badge_patreon]: https://ionicabizau.github.io/badges/patreon.svg
124[badge_amazon]: https://ionicabizau.github.io/badges/amazon.svg
125[badge_paypal]: https://ionicabizau.github.io/badges/paypal.svg
126[badge_paypal_donate]: https://ionicabizau.github.io/badges/paypal_donate.svg
127
128[patreon]: https://www.patreon.com/ionicabizau
129[amazon]: http://amzn.eu/hRo9sIZ
130[paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RVXDDLKKLQRJW
131
132[license]: http://showalicense.com/?fullname=Ionic%C4%83%20Biz%C4%83u%20%3Cbizauionica%40gmail.com%3E%20(https%3A%2F%2Fionicabizau.net)&year=2015#license-mit
133[website]: https://ionicabizau.net
134[contributing]: /CONTRIBUTING.md
135[docs]: /DOCUMENTATION.md