I made this regex but it is not working.
I got this example string: ('/test/test/test/test-Test/TEST/test.sql'),
my bash code:
if [[ ${arrayQuery[$i]} =~ ([a-z0-9]+)\/([a-z0-9]+)\/([a-z0-9]+)\/([a-z0-9-]+)\/([a-z0-9]+)\/([a-z0-9]+).([a-z0-9]+) ]]; then
queryName=$1
echo "test $queryName"
fi
it is not priting anything can anyone explain my why this is not working?
i tried my regex on regex101.com and the regex did work on this website.
you need to escape the dot, otherwise it matches any character
your example string contains uppercase, but your regex only accepts lowercase letters
(edit: no quoting needed)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With