Comments (5)
Fixed by #6. Released in v1.2.0.
from regexgen.
#6 didn’t fix this — it just made it easier to fix it. This issue is a change request about the regexgen
return value. TL;DR IMHO, it makes more sense to have regexgen(foo)
return a string instead of a regular expression object. WDYT?
from regexgen.
Another option would be to just return the Trie from regexgen. Then the user could call toString
or toRegExp
themselves.
I do like the convenience of just returning a RegExp though. You could do regexgen(words).source
to get a string without the slashes when combining. Is your main concern with bugs in JS implementations? The one you linked seems to have been fixed in v8. Are there others you know of?
from regexgen.
Another option would be to just return the Trie from regexgen. Then the user could call
toString
ortoRegExp
themselves.
I like this option a lot. As a bonus, doing so would match the Regenerate API. :)
Is your main concern with bugs in JS implementations […]
I don’t know of any others off the top of my head, but if the risk of JS engine bugs can be avoided, then that’s a plus in my book.
That said, my main concern is that the API — in this case, the return value — should match the common use case, not the uncommon one. But perhaps I’m wrong in thinking that getting the pattern as a string is the most common/sensible use case.
I do like the convenience of just returning a RegExp though.
Could you point me to some examples of where you’re using this pattern (see what I did there)? Are you using regexgen at runtime?
from regexgen.
Are you using regexgen at runtime?
No, but my build scripts don't need to combine regexes. So I just do regexgen(words, 'g')
instead of something like '/' + regexgen(words) + '/g'
.
from regexgen.
Related Issues (20)
- Generated pattern doesn’t match one of the input words in some cases HOT 1
- ES6 Escaping Support HOT 12
- Changelog
- SyntaxError: Invalid regular expression: Range out of order in character class HOT 2
- Strange behaviour with Cyrillic regexes
- Different output result with different word order HOT 2
- Use original character instead of id with unicode prefix
- Wrong regular expressions with regard to unicode codepoints HOT 4
- Empty input string throws TypeError
- Q: Negative look aheads HOT 1
- FYI: Rust port of regexgen with additional functionality HOT 3
- Sub-optimal regex containing unnecessary repetitions
- Please mininify HOT 1
- regexgen bug in minimize() / output depends on order of Trie#addAll input HOT 4
- Produce illegal regexes when passed \b in the inputs
- What does the parameter mean? HOT 1
- Repeating the same word in a string may produce a wrong result HOT 2
- Electron app and a thank you HOT 1
- How to generate regex for invalid strings HOT 1
- [question] revert the process HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from regexgen.