Extract part of the string which matches a regular expression

expr

  • Evaluate expressions and manipulate strings.
    More information: <https://www.gnu.org/software/coreutils/expr>.
  • Trick copyright: tl;dr; <https://github.com/tldr-pages/tldr>

echo $(expr {{string}} : '\({{regular_expression}}\)')

click the source code to copy install expr on any operating system with command-not-found.com