4 ms·
sed seriously needs a Perl-regex mode... it's stuck in the Basic/Extended Regex syntaxes, which feel prehistoric and don't support the syntax that you will lear
by j1elo 6y ago
sed seriously needs a Perl-regex mode... it's stuck in the Basic/Extended Regex syntaxes, which feel prehistoric and don't support the syntax that you will learn in practically any modern regex tutorial.
Maybe they could take the opportunity to add that. Otherwise I end up needing to
sed -i 's/sed -i/perl -pi -e/g' *
- eru 6y agoKeep in mind that Perl regexen can not be recognized in linear time.
- tyingq 6y agoIt looks like they did consider it: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22801 https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22801
- bewuethr 6y agoSed isn't part of the coreutils, though, so this would be outside of the scope of at least this project. There is https://github.com/chmln/sd https://github.com/chmln/sd written in Rust, but it's far from a sed replacement – it's reducing it to search and replace for fixed strings, as far as I can tell.
- chubot 6y agoFWIW this is one reason I designed the Eggex sublanguage of Oil to translate to extended regexps: so you can use it with egrep, awk, and sed --regexp-extended. https://www.oilshell.org/release/latest/doc/eggex.html https://www.oilshell.org/release/latest/doc/eggex.html It really annoys me to have to remember multiple syntaxes for regexes in shell scripts! Also, even if you added Perl syntax to sed today, it wouldn't be available everywhere. Oil isn't available everywhere either but there are some advantages to having the syntax in the shell rather than in every tool. (It's also easy to translate eggex to the BRE syntax or Perl syntax, but nobody has done so yet)
- j1elo 6y agoAlbeit the typical first reaction might be that of XKCD 927 (I must confess it was mine, at least), I believe that the regular expressions area is territory that could see some innovation. If told to pick just one feature from eggex, I'd choose the ability to parse statically! FWIW I think this deserves a submission of its own, so here it is: https://news.ycombinator.com/item?id=26408510 https://news.ycombinator.com/item?id=26408510