Hacker News new | past | comments | ask | show | jobs | submit login

If you want to do (relatively) simple pattern matching in a posix-compliant way, `expr`[1] can match BREs, and even return a capture group.

1: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/e...




As someone who enjoys shell scripting I don't think I have ever used the "expr" command. this astonishes and baffles me because I used to read the man pages for fun, I even had a little script to pick a random page. So thanks a bunch for bringing it to my attention.

My only guess as to why I am unfamiliar with the command is that perhaps younger me failed to figure out "expression" means regular expression. It only clicked this time because of your comment and the see also: re_format link at the bottom.

http://man.openbsd.org/expr


Yeah it's slightly obscure for a lot of people I think: most who do know of it seem to associate it purely with arithmetic, and rightly use `$((...))` instead.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: