4 ms·
Regex generator: Give sample text, look for known patterns, gives a regex
- stevejohnson 16y agoWeird, I had a project doing this exact same thing, just not as far along and not very well documented. I never actually had a use for it, just thought it was a cool problem. I had a nice functional algorithm for doing it. (Again, not documented except through some graphviz output.) Seeing this, I may stop working on it. https://github.com/irskep/t-reg https://github.com/irskep/t-reg
- riffraff 16y agoI believe I once ripped off your code :) I have a simple script that looks in my logs for timing reports like did X in 12345ms Z for <arandom non constant string> in 98765ms and then summarizes them, but the grouping is done based on ad hoc regular expressions. The obvious next step was trying to make it smart enough that it recognizes similar lines and generated the patterns itself, but avoiding making it over generalized/omnicomprehensive. I still cannot find a good solution :(
- dlsspy 16y agoThat's kind of neat. There were a bunch of web-based clones of "M-x regexp-builder" out there for a while. This is the first one that actually looks like it does something more interesting.
- alttab 16y agoThe feature that auto identifies IP addresses from valid input examples and uses a well known IP address regrex could save you some time.
- DTrejo 16y ago:) glad you found my post helpful, where I mention it http://news.ycombinator.com/item?id=2129839 http://news.ycombinator.com/item?id=2129839
- julian37 16y agoHeadache-relieving maybe, but also eyesore-inducing. Some simple, good advice for choosing color combinations is that in terms of HSB, never vary more than two aspects of a color. That is, you can vary hue and saturation, but then don't vary brightness. Or, vary hue and brightness, but leave saturation constant. Or vary saturation and brightness for the same hue. This is simplifying matters a lot but it's a fairly good starting point. There's also this awesome site: http://colorschemedesigner.com/ http://colorschemedesigner.com/
- stettberger 16y agoHm, yeah Regular Expressions are great, but they are also fragile and slow. The generator will, from what I se only generate very strict regexes, that will break if the input differs just a little bit.
- rue 16y agoIt really isn't that difficult for a programmer to learn how regexps work and construct your own rather than relying on fragile tools.
- henrikschroder 16y agoAgree, I wouldn't use that or any other tool to construct regexps, but I am using http://www.regexbuddy.com/ http://www.regexbuddy.com/ to test, debug, and refine the ones I've made.
- npongratz 16y agoI use http://gskinner.com/RegExr/ http://gskinner.com/RegExr/ for similar reasons; it's free (doesn't even have ads), though not as powerful as RegexBuddy. Allows for a very quick test-debug-refine cycle, making clear what is matched with realtime highlighting. I'm not affiliated in any way, just very happy with the service.
- mbesto 16y agoAwesome! Great for someone who is just starting out programming and has a hard time conceptualizing regex.
- chli 16y agoI use that to generate my regular expressions and test them : http://www.ultrapico.com/Expresso.htm http://www.ultrapico.com/Expresso.htm