Or simplify the whole approach:
ls apache-tomcat*|sed -r 's/^.*-([0-9.]+)\..*/\1/'
Less tools and it gives you version numbers.
PS: Following @Nemo's recommendations: we let the globbing shell and prior knowledge take care of half the work (just list things that actually look like apache-tomcat). When piping ls' is output to another tool, -1 is debatable, so we get rid of it. sed accepts values ββfrom ls that match the beginning of the line to the first, followed by a digit, the bracket remembers all the numbers and letter periods, and then we map the rest of the line to the end of the line (implicit). And then the whole match is replaced by catchy numbers and periods.
source share