I have followed this answer to implement the bash regex
#!/bin/bash
MYVAR=ho02123ware38384you443d34o3434ingtod38384day
MYVAR=${MYVAR//[[:alpha:]]/X}
echo ${MYVAR//[[:digit:]]/N}
However, when I try with a more complex regex, it doesn't replace anything:
#!/bin/bash
PREVIOUS_CONFIGURATION=`cat /etc/apache2/sites-available/user-domain.conf`
NEW_CONFIGURATION=${PREVIOUS_CONFIGURATION//ServerName .+?\n/testbro}
echo "$NEW_CONFIGURATION"
exit 1
This is how my file user-domain.conf
looks like:
ServerName CUSTOM_USER_DOMAIN
ServerAdmin webmaster@localhost
DocumentRoot /home/sifoo2/server2.wassap.io
<Directory /home/sifoo2/server2.wassap.io/>