7 ms·
AutoRegex
- deleted 4y ago[deleted]
- ggurface 4y agoDoesn't work for me. > any word that has a penultimate character of a > .*[a-z]n$
- polskibus 4y agoI’d bet users would’ve preferred to provide examples of input and output to get the regexp they want , instead of designing it in plain English.
- asicsp 4y agoSomething like https://regex-generator.olafneumann.org/ https://regex-generator.olafneumann.org/ ?
- texaslonghorn5 4y agoThat seems like a computationally challenging problem. To avoid .+ you would have to include non matching examples and then I don't know how similar to the matches / specific those would have to be.
- asah 4y agoPlain English has the benefit that you can use the microphone/dictation on your cellphone...
- wtetzner 4y agoWhy would you need to generate a regex on your cell phone?
- mutant 4y agoJust... Learn regex. Jeez.
- Cyberdog 4y agoHaven't tried it since I'd rather not sign up for an account. But regarding this example: Minimum eight characters, at least one letter, one number and one special character >> ^(?=.*[A-Za-z])(?=.*d)(?=.*[@$!%*#?&])[A-Za-zd@$!%*#?&]{8,}$ I assume the "d" characters here are supposed to be "\d" but the backslashes wandered off somewhere. Not sure if that's just in the example or the actual output from the AI. Some of those special characters like "*" and "$" need a backslash too. Also, this pattern will not allow any character which is not a letter, number, or in that very finite list of special characters - so no spaces, no carets, no quote marks or apostrophes, etc. Not allowing certain printable characters in a password is a bad practice (I won't complain too much if you forbid the non-printable ones).
- asicsp 4y agoAll words starting with the letter "n" and ending with "g", case insensitive >> /^nw*g$/i Yeah, seems like backslash got gobbled up in some sort of parsing before what gets displayed on the site. Should be `\w` here. Regarding your other point, characters like `*` won't need escaping within character class. Not sure why only those particular set of characters are deemed "special characters" - why not `-`, `=`, parentheses, curly braces, etc? Also, the site should specify which regex flavor is being generated, I'd guess JS. All said, it is good to see tools to help with regex, as long as the solutions will be tested to make sure it fits their particular problem.
- Cyberdog 4y ago> Regarding your other point, characters like `*` won't need escaping within character class. Really? Huh. I've been escaping them anyway, and I think I'll continue to do so just to avoid ambiguity when reading patterns. I was about to end this post with "an extra backslash never hurt anybody" but then I realized that this is HN and writing that would surely prompt someone to reply with some bizarre case where an extra backslash caused a cascade of failures which cost a company fifteen million dollars and/or killed 43 people.
- asicsp 4y ago
- MiddleMan5 4y agoI always imagined having a tool like this! Really psyched to have something to play with!
- memorable 4y agoA tool like this really cuts the time!
- unsignedint 4y agoNot an apple to apple comparison, but if you are trying to regex with help of software, my daily driver of building regex is RegexBuddy [1]. Not only makes building and testing regular expressions easy, but this pretty much covers all the Regex variants in the wild. (And comes with an excellent help file.) The same author also make variant called RegexMagic [2] which probably would have closer premise with AutoRegex (less NN part, perhaps) as it is designed to make Regex without too much knowledge of regex, but I don't know how well it works as I haven't used it much... [1]: https://www.regexbuddy.com/ https://www.regexbuddy.com/ [2]: https://www.regexmagic.com/ https://www.regexmagic.com/
- walls 4y agoregex101 does almost all of this but in the browser!
- texaslonghorn5 4y agoI typed in > Email > English → RegEx > 95 > GO > \w+@\w+\.\w+ That's an interesting email regex.
- iforgotpassword 4y agoThat's not that wrong though. What does it do for queries like "all male English names" or "comfortable temperature range"?
- memorable 4y agoFor "comfortable temperature range", it generates: (\d+\.?\d*)\s?-\s?(\d+\.?\d*) And for "all male English names", it generates: [A-Z][a-z]+ The first one might be good, but the latter seems rather unsophisticated.
- diarrhea 4y agoAll male English names is just a list. It doesn’t follow a grammar. Its regex would be akin to (John|Jane|Alice|Bob) and so on. It’s not a case for regex. In fact, I’ve found success in replacing regex with regular string operators (length, contains substring, doesn’t contain substring, starts with a capital letter, …) of the language at hand, then do final regex passes for whatever is left at the end. It’s infinitely more readable and debuggable. I’ve grown to avoid regex when possible.
- tgv 4y agoI typed "an email address" and it came up with [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} which is similar, but has some interesting differences. That shows it's black-box association. Then I tried "my email address" and this came out, line break included is john.doe@example.com My email address is \w+\.\w+@\w+\.\w+ "An identifier" vs "a Javascript identifier" does work as expected, but "a number" and "a floating point number" don't. "A quoted string" doesn't escape the quotes inside, but if you add "with escaped quotes" it does. So, it's cute, and might set you on the right track, as long as you study the output a bit.
- gnulinux 4y agoAll words starting with the letter "n" and ending with "g", case insensitive >> /^nw*g$/i This is not right. That should be a "\w" instead of "w".
- curiousgal 4y agoSame with the last one, it should be \d instead of d. Seems like an escape character issue.
- emilfihlman 4y agoIt's otherwise wrong, too. It shouldn't have ^ or $, and \w matches non word characters. It should be /n[a-z]*g/gi
- spaniard89277 4y agoMmm, it produces an expression matching the input? You should put some examples. I'm a noob but AFAIK there are different regex engines out there, which one is this output? I remember trying other regex generators in knime and not working.
- kseistrup 4y agoAlso regex-related: Pomsky: https://pomsky-lang.org/ https://pomsky-lang.org/ (formerly Rulex)
- nerdponx 4y agoI've seen a handful of libraries and DSLs that are intended to replace regex now. It might be interesting to compile a list of them and attempt to compare them.
- colordrops 4y agoI don't trust regular expressions that I wrote, let alone some doped up parameter sniffing AI.
- memorable 4y agoYou can always use tools like Regex101[0] to verify if they actually work or not. I have tried a few generated by the AI, and it seems to do the job most of the time. [0]: https://regex101.com/ https://regex101.com/
- croes 4y agoYou still could have edge cases you don't want or want
- chii 4y agoif you have an edge case you know you want, you could add the description into the input of the AI. If you are afraid of unintended matches, that's a different problem, which you might also get writing the regex yourself! The solution, i reckon, is to create (may be even via the same AI?) a large list of matches, and you manually look thru to see if there's unintended matches.
- nonameking2026 4y agoor just if clause it - why spend 1 hour chasing down regex to save yourself from writing 3 lines of code.
- eurasiantiger 4y agoBecause application performance matters more than developer performance.
- episteme 4y agoI thought Regex was typically less performant than string operations?
- rcshubhadeep 4y agoDid a hobby project a while ago, just the reverse. Wrote a blog post - https://medium.com/codist-ai/generating-natural-language-description-of-regex-using-deep-learning-679248a95dab https://medium.com/codist-ai/generating-natural-language-des... (colab - https://colab.research.google.com/drive/1QibOifIJQB2tfLyy_mmw8N9LpchDWnIz https://colab.research.google.com/drive/1QibOifIJQB2tfLyy_mm...) Also gave a pycon talk - https://www.youtube.com/watch?v=Zugbqg9HFHQ https://www.youtube.com/watch?v=Zugbqg9HFHQ It was fun, achieved good result but did not need a monster like GPT3!
- vladdoster 4y agoNeeds a way to delete your account
- croes 4y agoThat's why disposable email addresses exist
- memorable 4y agoI have played with this for a while, and here are some prompts that might be interesting. Prompt: "URL regex" ^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$ Prompt: "Email regex" /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,})) This one's weirdly sophisticated for some reason. Prompt: "An HTML tag with a close tag and attributes" <([a-zA-Z]+)[^>]*?(?<!\/)>.*?<\/\1>
- valvar 4y agoEmail addresses are notoriously hard to parse.[0] I'd wager that one probably misses a bunch of corner cases. [0] https://www.regular-expressions.info/email.html https://www.regular-expressions.info/email.html
- tragomaskhalos 4y agoThis is all true, but suspect that the issue is mostly self-correcting since anything other than an extremely vanilla email address is likely to run into an infuriatingly high number of rejections precisely because the software at the other end has taken an overly simplistic view of what is allowed, forcing the owner to change it out of sheer frustration.
- mdaniel 4y ago> Prompt: "An HTML tag with a close tag and attributes" Obviously trained on a data set that didn't include <h1> This whole thread is why I'm not scared of Copilot or similar taking away jobs anytime soon, since bug fixing is way harder than writing code
- irony123 4y agoExcellent. Worked for me. The output can modified but this provide a great start. I do regex so seldom I can't remember notation for lookahead for example which this provides.
- revskill 4y agoHmmm, it might works, but need a unit test to verify.
- ramigb 4y agoWhy do I have to sign up?
- deleted 4y ago[deleted]
- skyfalldev 4y agoYou also can use this for general GPT-3 queries, which is quite cool!
- adamwintle 4y agoHow did you do that?
- ricardobayes 4y agoIf we only could get safari to support lookbehind regex that would be nice.
- georgia_peach 4y agoIt is surprising / not surprising to see the lengths people go to not learn regex. There's not much to it. If you're just starting out, find a good reference, and memorize it. Mastery is another thing entirely, but it always is. In *nix land, a decent reference is built-in: `man awk` and jump to the "Regular Expressions" section.
- jwilk 4y agoThere are many awk implementations, so whether that reference is decent or not may vary. It looks like on BSDs, there's so such section at all.
- georgia_peach 4y agoTested on Linux, OpenBSD, & Mac: POSIX: man 7 re_format PCRE: man pcrepattern PCRE2: man pcre2pattern PCRE may be a "works on my machine" thing, but POSIX should be there.
- anyfactor 4y agoAs a web scraper, thank god for .*? or to be exact [\s\S]*? Does 90% of what I need.
- tragomaskhalos 4y ago"Something I can use to grep the word list on my Mac to cheat at Worldle. My remaining letters are ...., my green letters thus far are .... and my yellows are ..."
- gd3kr 4y agoHey! I’m the creator of www.autoregex.xyz (@gd3kr on twitter) I originally built it as a small side project in a couple days, I was absolutely not expecting a response this massive. I realise concerns about email and password sign up, and I built it in an hour-ish with firebase auth as a temporary solution to capping the sudden surge in GPT3 requests to the server after the twitter post gained traction. Im working on a better approach to that involving not having to create an account. Otherwise, all suggestions are absolutely welcome. Please tell me how I can make this a better experience for everyone.
- knolan 4y agoYou could probably include a ‘Why do I need to sign up?’ disclaimer.
- kelnos 4y agoWas curious to try it, but got turned off when asked to create an account, and didn't bother.
- mkl 4y agoTwo of your three examples are incorrect as they're missing backslashes. /^nw*g$/i should be /^n\w*g$/i and (?=.*d) should be (?=.*\d).
- chowells 4y agoSo I was talking to a friend about this, and he thought this was a parody because of all the obviously incorrect results you were highlighting in the Twitter thread. Other people have mentioned the \ escapes going missing, but my friend called out https://twitter.com/gd3kr/status/1545495732265766913 https://twitter.com/gd3kr/status/1545495732265766913 as so hilariously wrong that it couldn't have been anything other than a parody. Is this really a parody, or is it just another example of people not actually reading GPT-3 output carefully enough to notice it's nonsense?
- gd3kr 4y agoHey, no it’s not a parody lmao. I shipped it because realised it could have at least some utility while building it. To be fair, the wrong examples would be an oversight on my part, but I thought of them being more of genuine benchmark of what GPT3 was capable of; sort of like an experimental feature. I’m working hard on refining the results by fine tuning DaVinci and getting the output as close to ideal as possible — I think there’s a lot of potential there. In the end, even boosting a user’s productivity marginally is a win in my book, and as a lot of people have pointed out, it’s already doing that to some extent.
- wruza 4y agoBtw, does anyone know a library/program which can reverse engineer a regex from multiple source strings? E.g. 14:51 [info] 51 some message … more of 51 lines … 15:22 [error] 24 error! … more of 24 lines … ^(\d\d:\d\d) \[(info|error)\] (\d+) (.+)$ Or maybe not a regex, but a structured pattern.
- junon 4y agoI know this comment isn't helpful on its own, but yes this exists. I've seen it before. I just have no idea what it was called or how to find it again. EDIT: Ah no, sorry. Was thinking of the other way around[0]. 0: https://www.npmjs.com/package/regex-to-strings https://www.npmjs.com/package/regex-to-strings
- tomerv 4y agohttp://regex.inginf.units.it/extract/ http://regex.inginf.units.it/extract/
- eurasiantiger 4y agoJS has String.prototype.replaceAll, which can take a regex with multiple capture groups and output them as separate params to a callback function. This can be used to create a functional DSL which generates the regexes and callbacks.
- ailef 4y agoTechnically .* is a valid regex for those strings, so the issue here is not only to reverse engineer them, but to do so in a way that's meaningful for the person who has to use it after. It shouldn't be hard to start with .* and resursively split it in two parts that still match the input strings, but I believe you will end up with matching but useless regexes.
- manx 4y agoOne probably wants to provide a set of matching and a set of non-matching strings. Then the software would output a regex and some edge-case matching strings and non-matching strings. This could be built using set operations on deterministic finite automata (dfa). Every regex is equivalent to a dfa. You can now construct automata for every positive and negative example input. Then calculate the union for all positive examples and the union for all negative examples. And finally calculate the difference between the two unions. Convert the resulting automaton back to regex. https://scanftree.com/automata/dfa-union-property https://scanftree.com/automata/dfa-union-property
- napier 4y agoThis is the kind of use case I’d like to see more of! Less of the p-zombie copywriting neoplagiarism services with pot-luck output, more GPT-as-backend functional apps as productivity multipliers, if that makes sense.
- bruhhh 4y agothe font is so tiny on the website preview I cant read anything
- 5350-uiop-1130 4y agoI definitely need something like this. My brain seems to insta-delete all Regex knowledge after 1 week. However, why do I need to sign up to test it. I'm guessing there is some paywall after. This feels like that github co-pilot rugpull.
- Terry_Roll 4y agoDifferent programming languages use different forms of RegEx, it doesnt suggest it caters for this difference.
- ViraCz 4y agodamn this was good
- sourabhv 4y agoSwitch from "regex to english" and write "email". Instead of saying it will match the string "email", it says the opposite, english -> regex conversion > regex = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i > This regular expression is used to match an email address. It starts by matching any character that is not a space or the "@" symbol, followed by the "@" symbol, then any characters that are not a space or the "." symbol, followed by a "." character, and finally any characters that are not a space.
- SMAAART 4y agoMy prayers have been answered.
- layer8 4y ago> difficult to […] comprehend You’ll still have to fully comprehend the auto-generated regex to make sure that it really does what you want. So the tool may help with coming up with a suitable regex, but doesn’t remove the need for comprehension.
- emilfihlman 4y ago>All words starting with the letter "n" and ending with "g", case insensitive >> /^nw*g$/i The example regex is completely wrong, it should be /n[a-z]*g/ig
- PenguinRevolver 4y agoTried RegEx → English: \"object\": \[(.*?)\] ---- The regular expression matches a string that contains "object": followed by a space and an open bracket, then any characters, then a close bracket. The characters between the open and close bracket are captured in a group. Pretty cool.
- yoav_lavi 4y agoI created Melody (https://github.com/yoav-lavi/melody https://github.com/yoav-lavi/melody) for the same reasons you've mentioned in the website. I knew AI would try to replace me one day, but I didn't think it'd be so soon. Kidding of course, looks really cool!
- amrrs 4y agoHere's how you can do it without GPT-3 (using BLOOM an opensource alternative) https://twitter.com/1littlecoder/status/1545818058153140224 https://twitter.com/1littlecoder/status/1545818058153140224