Removesarangeofcodepointsfrom`start` to `end`(inclusive)fromtheset.Bothcodepoints(numbers)andsymbols(stringsconsistingofasingleUnicodesymbol)areaccepted.
```js
regenerate()
.addRange(0x000000,0x10FFFF)// add all Unicode code points
.removeRange('A','z')// remove all symbols from `A` to `z`
.intersection(whitelist)// remove all code points from the set except for those in the `whitelist` set
.toString();
// → '[ai]'
```
###`regenerate.prototype.contains(value)`
Returns`true` if the given value is part of the set, and `false`otherwise.Bothcodepoints(numbers)andsymbols(stringsconsistingofasingleUnicodesymbol)areaccepted.
Ifthe`bmpOnly` property of the optional `options` object is set to `true`,theoutputmatchessurrogatesindividually,regardlessofwhetherthey’relonesurrogatesorjustpartofasurrogatepair.Thissimplifiestheoutput,butitcanonlybeusedincaseyou’recertainthestringsitwillbeusedondon’tcontainanyastralsymbols.
NotethatlonelowsurrogatescannotbematchedaccuratelyusingregularexpressionsinJavaScriptwithouttheuseof[lookbehindassertions](https://mathiasbynens.be/notes/es-regexp-proposals#lookbehinds), which aren't yet widely supported. Regenerate’s output makes a best-effort approach but [there can be false negatives in this regard](https://github.com/mathiasbynens/regenerate/issues/28#issuecomment-72224808).
Ifthe`hasUnicodeFlag` property of the optional `options` object is set to `true`, the output makes use of Unicode code point escapes (`\u{…}`) where applicable. This simplifies the output at the cost of compatibility and portability, since it means the output can only be used as a pattern in a regular expression with [the ES6 `u`flag](https://mathiasbynens.be/notes/es6-unicode-regex) enabled.
Returnsaregularexpressionthatmatchesallthesymbolsmappedtothecodepointswithintheset.Optionally,youcanpass[flags](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#Parameters) to be added to the regular expression.
Regenerategetsevenbetterwhencombinedwithotherlibrariessuchas[Punycode.js](https://mths.be/punycode). Here’s an example where [Punycode.js](https://mths.be/punycode) is used to convert a string into an array of code points, that is then passed on to Regenerate:
```js
varregenerate=require('regenerate');
varpunycode=require('punycode');
varstring='Loremipsumdolorsitamet.';
// Get an array of all code points used in the string:
varcodePoints=punycode.ucs2.decode(string);
// Generate a regular expression that matches any of the symbols used in the string:
regenerate(codePoints).toString();
// → '[ \\.Ladeilmopr-u]'
```
InES6youcandosomethingsimilarwith[`Array.from`](https://mths.be/array-from) which uses [the string’s iterator](https://mathiasbynens.be/notes/javascript-unicode#iterating-over-symbols) to split the given string into an array of strings that each contain a single symbol. [`regenerate()`](#regenerateprototypeaddvalue1-value2-value3-)acceptsbothstringsandcodepoints,remember?
```js
varregenerate=require('regenerate');
varstring='Loremipsumdolorsitamet.';
// Get an array of all symbols used in the string:
varsymbols=Array.from(string);
// Generate a regular expression that matches any of the symbols used in the string:
Aftercloningthisrepository,run`npm install` to install the dependencies needed for Regenerate development and testing. You may want to install Istanbul _globally_ using `npm install istanbul -g`.
Oncethat’sdone,youcanruntheunittestsinNodeusing`npm test` or `node tests/tests.js`. To run the tests in Rhino, Ringo, Narwhal, and web browsers as well, use `grunt test`.
Togeneratethecodecoveragereport,use`grunt cover`.
##Author
|[![twitter/mathias](https://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") |