{"library":"regenerate","title":"Regenerate: Unicode-Aware Regex Generator","description":"Regenerate is a specialized JavaScript library designed to create regular expressions from a given set of Unicode symbols or code points. It intelligently handles the complexities of Unicode in JavaScript, particularly with astral symbols (those outside the Basic Multilingual Plane), by generating ES5-compatible patterns that correctly match these characters, typically using surrogate pairs. The library provides a fluent, chainable API to add, remove, and manage code points and ranges, allowing developers to precisely define character sets for their regexes. Currently at version 1.4.2, the package appears to be in a maintenance or stable state, having seen its last significant update several years ago, indicating a mature and feature-complete solution for Unicode-aware regex generation. It remains a valuable tool for ensuring cross-browser and historical JavaScript engine compatibility when dealing with advanced Unicode characters in regular expressions.","language":"javascript","status":"maintenance","last_verified":"Sun Apr 19","install":{"commands":["npm install regenerate"],"cli":null},"imports":["const regenerate = require('regenerate');","import * as regenerate from 'regenerate';","regenerate().add(0x1D306);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const regenerate = require('regenerate');\n\n// Create a set and add/remove code points and ranges\nconst unicodeSet = regenerate()\n  .addRange(0x60, 0x69) // Add U+0060 (`) to U+0069 (i)\n  .remove(0x62, 0x64) // Remove U+0062 (b) and U+0064 (d)\n  .add(0x1D306); // Add U+1D306 (a rare astral symbol)\n\n// Get the array of code points\nconsole.log('Code points:', unicodeSet.valueOf());\n// Expected: [96, 97, 99, 101, 102, 103, 104, 105, 119558]\n\n// Get the ES5-compatible regex string\nconst regexString = unicodeSet.toString();\nconsole.log('Regex string:', regexString);\n// Expected: '[`ace-i]|\\uD834\\uDF06'\n\n// Get the RegExp object\nconst regex = unicodeSet.toRegExp();\nconsole.log('RegExp object:', regex);\n// Expected: /[`ace-i]|\\uD834\\uDF06/\n\n// Example with direct arguments to regenerate\nconst directSet = regenerate(0x1D306, 'A', '©', 0x2603);\nconsole.log('Direct set regex string:', directSet.toString());\n// Expected: '[A\\xA9\\u2603]|\\uD834\\uDF06'\n","lang":"javascript","description":"This quickstart demonstrates how to initialize a `regenerate` set, add and remove individual code points and ranges, and finally generate both the regex string and the `RegExp` object. It also shows adding multiple values directly during initialization, including astral symbols.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}