Live data from Hacker News

A GPT 3.5 powered tool for generating regex

fuckregex.dev

11–20 of 24 posts

Re: A GPT 3.5 powered tool for generating regex

#12

Earlier quoted context omitted.

There are some neat tools for visualizing a regex like https://regexper.com/

There's also regexr.com which explains in more or less plain English what's happening

Personally a fan of https://regex101.com/

Re: A GPT 3.5 powered tool for generating regex

#13
Rate limit reached for default-gpt-3.5-turbo in organization org-cy3MEIpOsyQxMokN4SQON5gb on requests per min. Limit: 20 / min. Please try again in 3s. Contact support@openai.com if you continue to have issues. Please add a payment method to your account to increase your rate limit. Visit https://platform.openai.com/account/billing to add a payment method.

Ironically, it showed us the real future of AI

Re: A GPT 3.5 powered tool for generating regex

#15

This is what is gives to select names: /^[A-Z][a-z]+(?: [A-Z][a-z]+)*$/ I'm pretty sure quite a lot of people's names wouldn't be accepted by that. It helps if you add "even weird and foreign names", but who knows if that's actually enough to capture everything.

It might be good to say what you want in natural language or have it come up with that from your goal.

A regex that worked for all names would be extremely weak. I can’t imagine it being much more than testing valid characters.

Re: A GPT 3.5 powered tool for generating regex

#17
post #5

If you're using a regex it's a smell that there is a better tool for what you need to do. A ton of if statements is a much more readable way of writing code than regex.

Respectfully, no. If you're trying to write a full blown language parser then regexps are the wrong tool, but a 50 line function doing the job of a regexp has a really funky code smell. Comment your regexps*, and use a parser when your usecase outgrows regexps, but a blanket ban on regexps smells of "I'm not smart enough to understand them".

* https://www.oreilly.com/library/view/regular-expressions-coo...

Re: A GPT 3.5 powered tool for generating regex

#18

This is what is gives to select names: /^[A-Z][a-z]+(?: [A-Z][a-z]+)*$/ I'm pretty sure quite a lot of people's names wouldn't be accepted by that. It helps if you add "even weird and foreign names", but who knows if that's actually enough to capture everything.

It's not. I'll be the first one to link to the list of falsehoods programmers believe about names: https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-...

It should be required reading before being allowed to write code that'll operate on user profiles, but there's no such thing as a programming license, so this link will have to do.

Re: A GPT 3.5 powered tool for generating regex

#19

> /^(?:\/(?:\\\/|[^\/\n])+\/[gimuy]{0,5}|\\[^\n]|[^\n\\\/])+$/ What would you say was the query for this?

The regular version of ChatGPT can explain it pretty well. I asked it about your regex and it gave me a detailed breakdown; it's a bit too long to post it here but just to quote the [gimuy] part:

> [gimuy]{0,5}: This part of the pattern matches optional regex flags that can follow the closing forward slash of the regex pattern. The allowed flags are g (global), i (case-insensitive), m (multiline), u (unicode), and y (sticky). This part of the pattern matches zero to five of these flags, without repetition.

Full response: https://gist.github.com/nicolasff/3bbfb4cb8a514f58e140b887bf...

Post reply on HN