DPHPV = /usr/local/nginx/conf/php81-remi.conf;
I am unable to figure out how to match a string that contains any 2 digits:
if [[ "$DPHPV" =~ *"php[:digit:][:digit:]-remi.conf"* ]]
You are not using the right regex here as * is a quantifier in regex, not a placeholder for any text.
Actually, you do not need a regex, you may use a mere glob pattern like
if [[ "$DPHPV" == *php[[:digit:]][[:digit:]]-remi.conf ]]
Note
== - enables glob matching*php[[:digit:]][[:digit:]]-remi.conf - matches any text with *, then matches php, then two digits (note that the POSIX character classes must be used inside bracket expressions), and then -rem.conf at the end of string.
See the online demo:#!/bin/bash
DPHPV='/usr/local/nginx/conf/php81-remi.conf'
if [[ "$DPHPV" == *php[[:digit:]][[:digit:]]-remi.conf ]]; then
echo yes;
else
echo no;
fi
Output: yes.
php53-remi.confthen one way to do it isif [[ $DPHPV == php[[:digit:]][[:digit:]]-remi.conf ]].[[ "$DPHPV" =~ php[0-9][0-9]-remi.conf ]]*, but=~requires regular expressions, where the equivalent would be.*. Regexes alo aren't anchored, so the*/.*can just be skipped. Glob expressions (==/=instead of=~) require matching the entire string, so there you would need the*=~, which is written between quotes, is interpreted as a literal match, not as a regular expression. Further, the lone*in front of the regex does not have any meaning as regex. You can see it when doing i.e. a[[ x =~ * ]], which does not match.