Easy, it's uuuuuuuuh…
Easy, it's uuuuuuuuh…
Easy, it's uuuuuuuuh…
You have a problem, so you decide to use a regex. Now you have two problems.
The first language I was fluent in was Perl so PCRE is second nature to me. But then everyone decided they wanted their own regex dialects. And now there's a PCRE2? Why 2? Stay with 1, you're good together. What about the kids?
Your brains and mine work very very differently. Kudos to diversity.
It's great that you cherish that. Love that for you.
Which one of these commands is correct?
A:
sed -E 's/\b(\w+)\b/echo \1 | rev/g' file.txt
B:sed 's/\b\w+\b/echo & | rev/ge' file.txt
C:sed -E 's/(\w+)/$(echo \1 | rev)/g' file.txt
D:sed 's/\([a-zA-Z]\+\)/\n&\n/g; s/\n\(.*\)\n/\3\2\1/g; s/\n//g' file.txt
Chatty was so kind to transcribe. May contain errors.
The transcription of D is wrong. It should be:
sed 's/\([a-zA-Z]\+\)/\n&\n/g; s/\n\(.\)\(.*\)\(.\)\n/\3\2\1/g; s/\n//g' file.txt
also D is correct, assuming file.txt contains a list of words one per line
Chatty claims the correct answer to be:
I tried it my self and I conclude:
Thought so lol
A: didn't even try what by does B: Single quotes prevent execution C: there is no way to execute commands afaik so this won't work either D: that syntax is just wrong afaik
Google Lens says:
sh
Which one of these commands is correct? A sed -e 's/\b(\w+)\b/echo \1 | rev/g' file.txt B: sed 's/b\w+\b/echo & | rev/ge' file.txt Csed -e 's/(\w+)/$(echo \1 | rev)/g' file.txt D: sed 's/([a-zA-Z]\+\)/\n&\n/g; s/\n\(\)\(.*\)\(\)\n/\3\2\1/g; s/\n//g' file.tx
It's interesting that Google doesn't even get all the text. I had to manually extend the selection and that still misses the "t" on the end of answer D, munches C and more alarmingly changes the case for "-E".
OCR of fonts used to be a solved problem, but now we have AI, which can sort of do it sometimes
D i think. A and C aren't using capture groups right afaict.
I don't see anything wrong with the capture groups in A and C. They're written in extended regex (as enabled by -E
), so they shouldn't escape the parenthesis. Am I missing something?
Oh maybe you are right, I never use extended regexes for no reason
up
up
up
A
It's not just me being tempted .. right?
you should still give each command a try and let us know which one works
This is what VM’s are for.
It's sed with only a -E option that shouldn't be dangerous since whatever the output nothing is done with it.
Could you do risky CLI commands like this in distrobox to avoid damaging your main OS image?
Doesn't Distrobox expose (parts of) the real filesystem though?
D
What is meant to be accomplished here?
Yo ill be 100 with you.
Regex is where something like an LLM excells.
Don't rely on an llm for coding, but... This is exactly where it should be in your toolbox.
I don't disagree with this hot take. But the major difference is the sheer resources needed to have an LLM in place of a "do one thing right" utility like sed. In that sense, they are incomparable.
I think they're arguing for having the LLM generate the regex. And I certainly would not trust an LLM to do that right.
I mean fair.
I guess the caveat here should be fucking learn regex first, lmao.
Don't use it works not necessary. Google is probably still better if you're looking for regex for an email or something like that
And also don't just rely on its answer for prod.
this is funny i have totally opposite experience
I'm curious if you care to share more?
And we can see by the ratio that this was in fact a hot take.
A lot of lemmy is very anti-Ai. As an artist I'm very anti-Ai. As a veteran developer I'm very pro AI (with important caveats). I see it's value; I see it's threat.
I know I'm not in good company when I talk about its value on Lemmy.
Lol why are you getting downvoted this isn't even a hot take. You are 100% right regex is famously enigmatic even among experienced software engineers.
Yeah Lemmy used to have a core of tech Intel and that has slipped hard in the last 6 months.
Be what it do I guess. Dummies gonna dumb.
We are in this sea of like a million people who want to be cybersecurity professionals...
...and as a cybersecurity professional it's adorable when I see vehement dissent.
Like y'all, I've been doing this. And if you want a recommendation, pipe down lol.
If someone's made the regex before, sure.
I agree, but I don't want to use one until an open source one exists.
I some beef with this meme in that there really isn't a way to simply do this in windows. If anything, it demonstrates the upper level of capability and function using a cli shell. People who are looking for a windows replacement would never need to understand this command or even use a pipe / regex as they were unlikely to have been doing this kind of thing with windows anyway.
Who said anything about Windows? What's that have to do with the meme?
That's fair! I've always seen this community as an environment for advocating Linux use to Lemmings and much of the time the memes are comparative in nature to other options (ex the current to meme in this community about vendor lock in) so I'm just injecting my own historical view about this community. If it's not comparative; then why is it really that funny? In that case it just reads like an exam in a CIS final.
who in their right mind would try to do this on Linux
I could imagine a command like this being used as part of a CI/CD script doing static analysis in a virtualized environment where the build is running in a *nix container. There's more maintainable options as well (ie easier for an entire team of developers to understand / lower 'bus factor').
Lol someone is so mad about this they're going around downvoting all my replies. Guess that's easier than coming up with a thoughtful reply and actually conversing but whatever you do you boo
It's the 1 million Euro question.