6 ms·
ChatGPT blew my mind this morning — I was struggling with a regex, so asked it to help me. Here's how it went: https://i.imgur.com/PS6oPsq.png https://i.imgur.
by jw1224 4y ago
ChatGPT blew my mind this morning — I was struggling with a regex, so asked it to help me.
Here's how it went: https://i.imgur.com/PS6oPsq.png https://i.imgur.com/PS6oPsq.png
A pretty incredible developer experience, if you ask me!
- rstarast 4y agoImpressive! It's lying though when it claims its regexes match the empty parameter cases, right? (The regexes do what's asked, just explanation seems buggy.)
- jw1224 4y agoThat’s right. The other mistake it made was including the curly braces when capturing the first parameter. Despite this, for a regex amateur like me I was very impressed. It saved me all the time I’d normally spend head-scratching in Regex101, trying to remember how it works. Instead I could just jump there at the end, validate the matching, and make any small tweaks far easier.
- gavinsyancey 4y agoAlso, a LaTeX macro will grab the first token as it's argument if there are no curly brackets which the regex doesn't support ... Not entirely surprised as that's hard (impossible if you don't assume default catcodes) to get right and probably not worth it for most usecases but worth keeping in mind.
- jw1224 4y agoFor context, this is for a pretty strange use case — I was trying to preprocess user-submitted LaTeX with PHP, by replacing occurrences of a specific macro with simply the value of its first argument. The macro just colour-codes its first parameter presentationally, whilst the rest of the LaTeX needs to be passed to a compute engine for solving. The compute engine doesn't know how to "solve" a colour, hence why I'm trying to strip them out beforehand.
- spaceman_2020 4y agoWow! I've been learning how to code for a personal project but looking at this stuff, junior devs might be out of work soon.
- carom 4y agoWhich is unfortunate because then they will never become senior devs.
- terminal_d 4y agoSay it ain't so
- synaesthesisx 4y agoWait until the GPT-4 version is out, and seniors are in trouble too. People don’t realize, this is still in its infancy.
- roflyear 4y agoHahaha that's wild, but... I have to feel like it's abuse to use regex here!
- ShamelessC 4y agoShh, nobody tell them GOFAI didn’t pan out.
- LoganDark 4y agohttps://stackoverflow.com/a/1732454 https://stackoverflow.com/a/1732454
- jw1224 4y agoGiven an arbitrary LaTeX string... - which may contain 0 or more \parameter macros - of which each will either have one (\parameter{123}) or two (\parameter{123}{blue}) arguments ... besides regex, how else would you suggest replacing the entire macro with simply the value of its first argument (i.e. 123)? I can do it in one line with regex, but if there's an easier way, I'm all ears :)
- roflyear 4y agoI'd have to learn more about the problem! But at the end of the day if regex works for you it works for you :)
- j2kun 4y agowait, you had to correct it for it to produce a working regex?
- deleted 4y ago[deleted]
- aussieshibe 4y agoIf it only required one round of correction, it's already better at regex than I am.
- bugfix-66 4y agoLook at Section 8 and Section 9 here: http://tug.ctan.org/info/tex-nutshell/tex-nutshell.pdf http://tug.ctan.org/info/tex-nutshell/tex-nutshell.pdf How is ChatGPT's answer wrong? The regex is matching square brackets instead of the correct OPTIONAL curly braces. Unseparated arguments aren't handled. The regex for the id is also wrong. The leading slash is correct, but other than that, the whole fucking thing is wrong! And of course it can't handle macro calls within the macro arguments (nesting). It's just an absolute clusterfuck, from top to bottom. The chatbot gave its user a useless piece of garbage, and Hacker News doesn't know enough to throw it away. Instead, we parade it around like some great success! Fooled by a language model.
- aussieshibe 4y agoDid you mean to reply to someone else perhaps? The comment you replied to was a one line joke about being bad at regex. I didn't directly or implicitly make any claim about the quality of the output of the chatbot. It's unclear to me how my comment could be reasonably interpreted as "parading it around". On a tangent: > Fooled by a language model I suspect a reasonable person would understand this to be insulting on some level, so I assume you must have seen some other meaning/value in including it such that the "insultingness" is outweighed by the point you're making. I'm not seeing that point though, could you clarify?
- rkagerer 4y ago
- deleted 4y ago[deleted]
- cm277 4y agoIt basically gave me the same feeling of glee I got out of Google while it was still at stanford.edu: just a great UX and what feels like the correct answer on the first try. Google should be shaking in their boots.