I have a regular expression:
^(.+?)(\.[^.]+$|$)
which separates a file name and the file extension (if there is one) http://movingtofreedom.org/2008/04/01/regex-match-filename-base-and-extension/
Works perfectly fine in Perl
Say $FILE ='.myfile.form.txt'
$1 is '.myfile.form' and
$2 is '.txt', as they should be
I know Bash regex and Perl regex aren't the same, but I've never had a problem with Bash Rematching until now
But when I try to use in in a Bash script as, say...
FILE='.myfile.form.txt'
[[ $FILE =~ ^(.+?)(\.[^.]+$|$) ]]
${BASH_REMATCH[1]} will just have the entire file name (.myfile.form.txt), and nothing in ${BASH_REMATCH[2]}
I'm wondering what's wrong/going on here
Thanks for any help!