Fix regression in upgrade step logic which filtered out rc dirs

feeccd1 incorrectly anchored the end of the directory names in order to
weed out false positives.  Unfortunately, in doing so, it also filtered
out rc upgrade directories (creating false negatives).

Fix this regression by using RT::Handle's version words and the standard
regex used in two other places in rt-setup-database.  This regex
accounts for rc dirs while also filtering out false positives.
Consolidate version dir matching into a standard regex available everywhere

Hopefully this will avoid divergent restrictions in the future.
Merge branch '4.0/missed-upgrade-steps-regression' into 4.0.17-releng
Merge branch '4.0.17-releng' into 4.0-trunk