News for hackers. Stuff that matters.
Re:The Greatest Regex Trick Ever (2014) by jrm4 on Thursday July 08, 2021 @05:59PM (#27778136)
Part of me reads these things and I'm like "neat trick", but most of the time they more-or-less prove to me that Regex is doomed to a steady and slow decline.

It's just not a particularly good "interface" for the task it is intended to achieve, a little more ability to be "verbose" at the possible price of succinctness I think would go a long way. I'm more-or-less waiting for the "blank" in: "blank" is to Python what Regex is to Perl.

Re:The Greatest Regex Trick Ever (2014) by gota on Thursday July 08, 2021 @06:02PM (#27778165)
I dream that we will have something like Copilot but exclusively for regex and working marvelously

"Find every 2nd instance of a dollar amount that is not encased in quotes" outputting <insert regex here> would be awesome

Re:The Greatest Regex Trick Ever (2014) by IgorPartola on Thursday July 08, 2021 @07:36PM (#27778907)
Please no. If you can’t understand the code, how can you possibly verify that what copilot or similar has produced is correct?
Re:The Greatest Regex Trick Ever (2014) by sellyme on Thursday July 08, 2021 @11:49PM (#27780298)
The same way I verify that my own regex is correct: by running a few test cases and then crossing my fingers.
Re:The Greatest Regex Trick Ever (2014) by LanternLight83 on Thursday July 08, 2021 @08:38PM (#27779342)
Just like programming tricks in any language supported by copilot:

a. Code, once provided, can be broken down and understood at a far easier level than is required for composition;

b. Worst case, try several test cases to both increase comprehension and reduce the chance of 'gottcha's.

Shouldn't be too hard to stick with option 'a' as clear best practice, looking up any operators or syntax that aren't immediately obvious, the advantage being that the AI can use obscure tricks that you aren't initially aware of but you still have the opportunity to review and understand the regex, becoming better over time. It's theoretically auto-generated, but practically computer-assisted.

Re:The Greatest Regex Trick Ever (2014) by IgorPartola on Thursday July 08, 2021 @11:36PM (#27780247)
That is the opposite of what most people will say. To most, reading someone else’s code is much harder than constructing their own. Try this one:

    @P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord ($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&& close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
Re:The Greatest Regex Trick Ever (2014) by klyrs on Thursday July 08, 2021 @08:51PM (#27779419)
Smartass answers only. Ask autopilot to write a proof with --nojargon so juniors will get it! Write a single unit test and call it good! Step through it in a debugger on that one unit test to be sure? Sure of what? I dunno but it sounds diligent...

When I watched Idiocracy, a small optimist in me said "but surely the techies..." That optimist has died. We're fucked

Re:The Greatest Regex Trick Ever (2014) by meepmorp on Thursday July 08, 2021 @08:29PM (#27779277)
Probably the way most people do - they run it over whatever examples they can think of at the moment as a check, and then forget about it till it breaks.
Re:The Greatest Regex Trick Ever (2014) by j1elo on Thursday July 08, 2021 @07:12PM (#27778747)
> I'm more-or-less waiting for the "blank" in: "blank" is to Python what Regex is to Perl.

This will sound like a forced joke but I genuinely didn't understand your phrase. I got stuck re-reading several times the "blank" in: "blank" part, but my mental language regex wasn't matching the expression.

I think the bug is caused by a bogus quote that causes a bad parameter expansion. My regex engine parses this better: the "blank" in: "blank is to Python what Regex is to Perl"

Off by one errors...

Re:The Greatest Regex Trick Ever (2014) by taneq on Friday July 09, 2021 @01:30AM (#27780722)
They're waiting for the X in "X : Python :: regexp : perl" - does this help?
Re:The Greatest Regex Trick Ever (2014) by unstatedAnswers on Thursday July 08, 2021 @11:53PM (#27780313)
Haha, I love your explanation of this! Human communication is difficult, and using syntax incorrectly makes it even moreso
Re:The Greatest Regex Trick Ever (2014) by lmm on Thursday July 08, 2021 @08:35PM (#27779322)
> I'm more-or-less waiting for the "blank" in: "blank" is to Python what Regex is to Perl.

Parser combinators

Re:The Greatest Regex Trick Ever (2014) by ralph84 on Thursday July 08, 2021 @08:02PM (#27779071)
Regex reminds me of sendmail.cf. Very clever and powerful, but no one writes configuration files that way any more.
Re:The Greatest Regex Trick Ever (2014) by IgorPartola on Thursday July 08, 2021 @07:38PM (#27778913)
I have to say I agree. Regex is arcane in the most bug-prone way.