0

Is there any way to natively escape a sequence in apt's regex?

I have a search, for example libpng++, where I want to literally match the ++ part of the string. I know that I can manually escape the ++ with \+\+, but I need to escape the string (since it comes to me as a variable) instead of simply the manually escape the individual characters.

I've tried apt-cache search libpng++, "libpng++", 'libpng++', \"libpng++\", \'libpng++\', \Qlibpng++\E, etc.

Is there any want to get this to work?

StephenG
  • 2,851
  • 1
  • 16
  • 36

2 Answers2

0

You can "treat" the variable before passing it to apt-cache, as in:

var="libpng++"
var=$(echo $var | sed 's|\([+*?]\)\\\1|g')
apt-cache search $var

Add any other special regex chars between [ and ] above.

-1

extra + should work. that is - libpng+++

balaganAtomi
  • 550
  • 8
  • 13