{"_id":"regexgen","_rev":"20-2111dc982b3dc9b3803e304cad01a731","name":"regexgen","description":"Generate regular expressions that match a set of strings","dist-tags":{"latest":"1.3.0"},"versions":{"1.0.0":{"name":"regexgen","version":"1.0.0","description":"Generate regular expressions that match a set of strings","main":"index.js","dependencies":{"jsesc":"^2.3.0","regenerate":"^1.3.2"},"devDependencies":{"mocha":"^3.2.0"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git+https://github.com/devongovett/regexgen.git"},"keywords":["regex","trie","regular","expression"],"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/devongovett/regexgen/issues"},"homepage":"https://github.com/devongovett/regexgen#readme","gitHead":"9ea0bee942ab019adc52c5f33d9973278f611e6a","_id":"regexgen@1.0.0","_shasum":"12a750319205917ecb249e72e946643dae03edc3","_from":".","_npmVersion":"3.9.5","_nodeVersion":"6.2.2","_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"dist":{"shasum":"12a750319205917ecb249e72e946643dae03edc3","tarball":"https://registry.npmjs.org/regexgen/-/regexgen-1.0.0.tgz","integrity":"sha512-7FivK55VCQfOy70uj14oCrZwfs0Q+oZ8QPLUqsAfPr0hxB5WAtvdmChxqivU2cMUhr8n/jokIX87sbujOMmlVw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAMTr0MVdMS/x1BEs3ldnla1ylERg6tT3rOh8o0nRE9KAiAgFLe5jkBhwNGyKZAtFR8NUrQmwu0wN+hZnlb+P/2ySg=="}]},"maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/regexgen-1.0.0.tgz_1482291772026_0.94065429456532"}},"1.1.0":{"name":"regexgen","version":"1.1.0","description":"Generate regular expressions that match a set of strings","main":"index.js","bin":{"regexgen":"bin/cli.js"},"dependencies":{"jsesc":"^2.3.0","regenerate":"^1.3.2"},"devDependencies":{"mocha":"^3.2.0"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git+https://github.com/devongovett/regexgen.git"},"keywords":["regex","trie","regular","expression"],"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/devongovett/regexgen/issues"},"homepage":"https://github.com/devongovett/regexgen#readme","gitHead":"87cbd9c0ef55de53791725e297d9445a20877f3b","_id":"regexgen@1.1.0","_shasum":"81f8236a29c85ac775b7e7d680206d413e57a316","_from":".","_npmVersion":"3.9.5","_nodeVersion":"6.2.2","_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"dist":{"shasum":"81f8236a29c85ac775b7e7d680206d413e57a316","tarball":"https://registry.npmjs.org/regexgen/-/regexgen-1.1.0.tgz","integrity":"sha512-JmPAjq+pNjl/iDsIwyEa9W7UlAe6H4zGaGGVLA8BxTcOaVHArS4NdBgbAOFlZRlogv9ljaz8ctswEWT055T0kg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBwK4S3yIjjorqGcKet1tXqHGpGX16n5z7j4R9fECCgqAiBsugGgoGrWdVIdWKxsdzCdKlrJHTcPnPMdebWJGRz4bA=="}]},"maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/regexgen-1.1.0.tgz_1482370281943_0.5031844319310039"}},"1.2.0":{"name":"regexgen","version":"1.2.0","description":"Generate regular expressions that match a set of strings","main":"index.js","bin":{"regexgen":"bin/cli.js"},"dependencies":{"jsesc":"^2.3.0","regenerate":"^1.3.2"},"devDependencies":{"mocha":"^3.2.0"},"scripts":{"test":"mocha"},"engines":{"node":">= 6"},"repository":{"type":"git","url":"git+https://github.com/devongovett/regexgen.git"},"keywords":["regex","trie","regular","expression"],"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/devongovett/regexgen/issues"},"homepage":"https://github.com/devongovett/regexgen#readme","runkitExample":"const regexgen = require('regexgen');\n\nregexgen(['foobar', 'foobaz', 'foozap', 'fooza']);","gitHead":"9663fbb2f1ff2532b9cc5d1058c6e02dece58e95","_id":"regexgen@1.2.0","_shasum":"41d57e1cb7d045f35cf8d53c7aab54b1d42321c8","_from":".","_npmVersion":"3.9.5","_nodeVersion":"6.2.2","_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"dist":{"shasum":"41d57e1cb7d045f35cf8d53c7aab54b1d42321c8","tarball":"https://registry.npmjs.org/regexgen/-/regexgen-1.2.0.tgz","integrity":"sha512-/lUnQqIwgEUd9mlp6aWXq+2nOfbn6+RE65pfIuIXtyNPf+zUuq6axeLXeQ996v7j2FVs8kYRr+9tBZo5lz/FCA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDUjBeOQxYZdMb20lVLS3vBNdrHX/9wa26KnXZ5CKkLdgIgY+D85U7z+yc4fQyLWLKPWt6A5xBP6zxlTeekBNGkdSk="}]},"maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/regexgen-1.2.0.tgz_1482426929510_0.9818714582361281"}},"1.2.1":{"name":"regexgen","version":"1.2.1","description":"Generate regular expressions that match a set of strings","main":"index.js","bin":{"regexgen":"bin/cli.js"},"dependencies":{"jsesc":"^2.3.0","regenerate":"^1.3.2"},"devDependencies":{"mocha":"^3.2.0"},"scripts":{"test":"mocha"},"engines":{"node":">= 6"},"repository":{"type":"git","url":"git+https://github.com/devongovett/regexgen.git"},"keywords":["regex","trie","regular","expression"],"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/devongovett/regexgen/issues"},"homepage":"https://github.com/devongovett/regexgen#readme","runkitExample":"const regexgen = require('regexgen');\n\nregexgen(['foobar', 'foobaz', 'foozap', 'fooza']);","gitHead":"743e8019ec822fe8e9b734182e2666ed76f789f0","_id":"regexgen@1.2.1","_shasum":"02e6a63e2764fd58cd7d488ebf0a46d02ce62b00","_from":".","_npmVersion":"3.9.5","_nodeVersion":"6.2.2","_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"dist":{"shasum":"02e6a63e2764fd58cd7d488ebf0a46d02ce62b00","tarball":"https://registry.npmjs.org/regexgen/-/regexgen-1.2.1.tgz","integrity":"sha512-GHL2DgSI1+V+gFeXELULxjb4Lk0+2gbjn/M74q0sadElif3etkR2wnjthtVXG9PAYgvxwhCAMmjfsi6f/JS3fw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHDP+PLMMKS3eS0aPk1odp5vF63y9uSNhoFHqn38UoBaAiAGs4AmTGnBmaT+napNhpJn/uqcr4pZJq2NWQgm97CpfA=="}]},"maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/regexgen-1.2.1.tgz_1482532683940_0.2562152799218893"}},"1.2.2":{"name":"regexgen","version":"1.2.2","description":"Generate regular expressions that match a set of strings","main":"index.js","bin":{"regexgen":"bin/cli.js"},"dependencies":{"jsesc":"^2.3.0","regenerate":"^1.3.2"},"devDependencies":{"mocha":"^3.2.0"},"scripts":{"test":"mocha"},"engines":{"node":">= 6"},"repository":{"type":"git","url":"git+https://github.com/devongovett/regexgen.git"},"keywords":["regex","trie","regular","expression"],"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/devongovett/regexgen/issues"},"homepage":"https://github.com/devongovett/regexgen#readme","runkitExample":"const regexgen = require('regexgen');\n\nregexgen(['foobar', 'foobaz', 'foozap', 'fooza']);","gitHead":"500357ae6f9e90c457d8890b16364167b8dd6572","_id":"regexgen@1.2.2","_shasum":"e57b46ff0b8a799f8b5caaa57a727834ed946069","_from":".","_npmVersion":"3.9.5","_nodeVersion":"6.2.2","_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"dist":{"shasum":"e57b46ff0b8a799f8b5caaa57a727834ed946069","tarball":"https://registry.npmjs.org/regexgen/-/regexgen-1.2.2.tgz","integrity":"sha512-XFTRu1jIIWCjNo3g8WQnX7P9hwZekP+J/e4jZZrcDP+mGcZGeEdY/mt2UpCLS2elbm3vuLH/Ny91SU6jUVB2hA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBUMEaslnOjaPfj1KVn1upY6d+lQfaJKTT/K9k+NgQbLAiApZzYrR/9Y4hoHJCOKNG2qFF2JAEDQkzzYswYEtg/z/g=="}]},"maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/regexgen-1.2.2.tgz_1482808005577_0.6752992656547576"}},"1.2.3":{"name":"regexgen","version":"1.2.3","description":"Generate regular expressions that match a set of strings","main":"index.js","bin":{"regexgen":"bin/cli.js"},"dependencies":{"jsesc":"^2.3.0","regenerate":"^1.3.2"},"devDependencies":{"mocha":"^3.2.0"},"scripts":{"test":"mocha"},"engines":{"node":">= 6"},"repository":{"type":"git","url":"git+https://github.com/devongovett/regexgen.git"},"keywords":["regex","trie","regular","expression"],"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/devongovett/regexgen/issues"},"homepage":"https://github.com/devongovett/regexgen#readme","runkitExample":"const regexgen = require('regexgen');\n\nregexgen(['foobar', 'foobaz', 'foozap', 'fooza']);","gitHead":"8f577c5b2fa3e8f371ba3ea23cd2e734cd2bdee7","_id":"regexgen@1.2.3","_shasum":"7d818c1c8a89ac3edd1eac22ba45541afba125a8","_from":".","_npmVersion":"3.10.9","_nodeVersion":"6.9.2","_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"dist":{"shasum":"7d818c1c8a89ac3edd1eac22ba45541afba125a8","tarball":"https://registry.npmjs.org/regexgen/-/regexgen-1.2.3.tgz","integrity":"sha512-4M1eFNj989h/TnXtILhiZN4a9B01ZR5EFMIyqyXqb7mHuw+dk7Gr87t4O4rEq3L+Dhb7WD6b7yCzmNF2YmrW+Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC64bI2slIthvWQndT46b+lj7IV3Z0Z1nkg1opjVr5I3AIhAMtbFVMVw95PBxpW3V1JMP6t0y0kT292rX/2DtKCrREW"}]},"maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/regexgen-1.2.3.tgz_1489872179495_0.5640633315779269"}},"1.2.4":{"name":"regexgen","version":"1.2.4","description":"Generate regular expressions that match a set of strings","main":"index.js","bin":{"regexgen":"bin/cli.js"},"dependencies":{"jsesc":"^2.3.0","regenerate":"^1.3.2"},"devDependencies":{"mocha":"^3.2.0"},"scripts":{"test":"mocha"},"engines":{"node":">= 6"},"repository":{"type":"git","url":"git+https://github.com/devongovett/regexgen.git"},"keywords":["regex","trie","regular","expression"],"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/devongovett/regexgen/issues"},"homepage":"https://github.com/devongovett/regexgen#readme","runkitExample":"const regexgen = require('regexgen');\n\nregexgen(['foobar', 'foobaz', 'foozap', 'fooza']);","gitHead":"3a3f8ae169e73b8ca4bca3935099b2ce0f34f81a","_id":"regexgen@1.2.4","_shasum":"4464af18f2d567718f2ddd43e288cee3ea1446fb","_from":".","_npmVersion":"3.10.9","_nodeVersion":"6.9.2","_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"dist":{"shasum":"4464af18f2d567718f2ddd43e288cee3ea1446fb","tarball":"https://registry.npmjs.org/regexgen/-/regexgen-1.2.4.tgz","integrity":"sha512-56B4W8SVDx9SRhZUzJAGthivItE1Og/61dvlcfHEzRALAmkWdW7s2Gd3uClpP0UuZhYTAzt91JR3I9bT193fPQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEmYdkpkT92YrxsMeRMqP97wS1w6DP8DWJpPisxJXx91AiEA5i3fw8VKIPaewrBk6kjChHxFLSLPNIjfyZPwmpOYb3s="}]},"maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/regexgen-1.2.4.tgz_1498934227015_0.8220122598577291"}},"1.3.0":{"name":"regexgen","version":"1.3.0","description":"Generate regular expressions that match a set of strings","main":"index.js","bin":{"regexgen":"bin/cli.js"},"dependencies":{"jsesc":"^2.3.0","regenerate":"^1.3.2"},"devDependencies":{"mocha":"^3.2.0"},"scripts":{"test":"mocha"},"engines":{"node":">= 6"},"repository":{"type":"git","url":"git+https://github.com/devongovett/regexgen.git"},"keywords":["regex","trie","regular","expression"],"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/devongovett/regexgen/issues"},"homepage":"https://github.com/devongovett/regexgen#readme","runkitExample":"const regexgen = require('regexgen');\n\nregexgen(['foobar', 'foobaz', 'foozap', 'fooza']);","gitHead":"7ef10aef3a414b10554822cdf6e90389582b1890","_id":"regexgen@1.3.0","_shasum":"b022f38e5120bb46fdcd37facb91168f15e6fe7a","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.9.4","_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"dist":{"shasum":"b022f38e5120bb46fdcd37facb91168f15e6fe7a","tarball":"https://registry.npmjs.org/regexgen/-/regexgen-1.3.0.tgz","integrity":"sha512-0BNTvyQBE8StSpjC5wPhydCTKP3SueHNOyjRiTM+vV3nip9UgFOZOjN6WJB7ikgcsEy5N5W6cT6xZCIdHcbvHA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDEkQyEHtBhQhFgwSvmwp6NuUma1dZMA7T6soPaqSZk/QIgUb6di6lSlA8R4jiMSCxI/7SP5PlTEHTSssg9feWbHpI="}]},"maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/regexgen-1.3.0.tgz_1499546104681_0.8064814079552889"}}},"readme":"# regexgen\n\nGenerates regular expressions that match a set of strings.\n\n## Installation\n\n`regexgen` can be installed using [npm](https://npmjs.com):\n\n```\nnpm install regexgen\n```\n\n## Example\n\nThe simplest use is to simply pass an array of strings to `regexgen`:\n\n```javascript\nconst regexgen = require('regexgen');\n\nregexgen(['foobar', 'foobaz', 'foozap', 'fooza']); // => /foo(?:zap?|ba[rz])/\n```\n\nYou can also use the `Trie` class directly:\n\n```javascript\nconst {Trie} = require('regexgen');\n\nlet t = new Trie;\nt.add('foobar');\nt.add('foobaz');\n\nt.toRegExp(); // => /fooba[rz]/\n```\n\n## CLI\n\n`regexgen` also has a simple CLI to generate regexes using inputs from the command line.\n\n```shell\n$ regexgen\nUsage: regexgen [-gimuy] string1 string2 string3...\n```\n\nThe optional first parameter is the [flags](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) to add\nto the regex (e.g. `-i` for a case insensitive match).\n\n## ES2015 and Unicode\n\nBy default `regexgen` will output a standard JavaScript regular expression, with Unicode codepoints converted into UCS-2 surrogate pairs.\n\nIf desired, you can request an ES2015-compatible Unicode regular expression by supplying the `-u` flag, which results in those codepoints being retained.\n\n```shell\n$ regexgen 👩 👩‍💻 👩🏻‍💻 👩🏼‍💻 👩🏽‍💻 👩🏾‍💻 👩🏿‍💻\n/\\uD83D\\uDC69(?:(?:\\uD83C[\\uDFFB-\\uDFFF])?\\u200D\\uD83D\\uDCBB)?/\n\n$ regexgen -u 👩 👩‍💻 👩🏻‍💻 👩🏼‍💻 👩🏽‍💻 👩🏾‍💻 👩🏿‍💻\n/\\u{1F469}(?:[\\u{1F3FB}-\\u{1F3FF}]?\\u200D\\u{1F4BB})?/u\n```\n\n\nSuch regular expressions are compatible with current versions of Node, as well as the latest browsers, and may be more transferrable to other languages.\n\n## How does it work?\n\n1. Generate a [Trie](https://en.wikipedia.org/wiki/Trie) containing all of the input strings.\n   This is a tree structure where each edge represents a single character. This removes\n   redundancies at the start of the strings, but common branches further down are not merged.\n\n2. A trie can be seen as a tree-shaped deterministic finite automaton (DFA), so DFA algorithms\n   can be applied. In this case, we apply [Hopcroft's DFA minimization algorithm](https://en.wikipedia.org/wiki/DFA_minimization#Hopcroft.27s_algorithm)\n   to merge the nondistinguishable states.\n\n3. Convert the resulting minimized DFA to a regular expression. This is done using\n   [Brzozowski's algebraic method](http://cs.stackexchange.com/questions/2016/how-to-convert-finite-automata-to-regular-expressions#2392),\n   which is quite elegant. It expresses the DFA as a system of equations which can be solved\n   for a resulting regex. Along the way, some additional optimizations are made, such\n   as hoisting common substrings out of an alternation, and using character class ranges.\n   This produces an an [Abstract Syntax Tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree)\n   (AST) for the regex, which is then converted to a string and compiled to a JavaScript\n   `RegExp` object.\n\n## License\n\nMIT\n","maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"time":{"modified":"2022-06-26T10:43:51.711Z","created":"2016-12-21T03:42:52.686Z","1.0.0":"2016-12-21T03:42:52.686Z","1.1.0":"2016-12-22T01:31:22.667Z","1.2.0":"2016-12-22T17:15:31.449Z","1.2.1":"2016-12-23T22:38:05.933Z","1.2.2":"2016-12-27T03:06:47.532Z","1.2.3":"2017-03-18T21:23:01.242Z","1.2.4":"2017-07-01T18:37:07.103Z","1.3.0":"2017-07-08T20:35:05.728Z"},"homepage":"https://github.com/devongovett/regexgen#readme","keywords":["regex","trie","regular","expression"],"repository":{"type":"git","url":"git+https://github.com/devongovett/regexgen.git"},"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"bugs":{"url":"https://github.com/devongovett/regexgen/issues"},"license":"MIT","readmeFilename":"README.md","users":{"webnicola":true,"chocolateboy":true,"sivan":true,"arteffeckt":true,"jerkovicl":true,"johnmichel":true,"psbolden":true,"tjfwalker":true}}