compare version numbers
===

I have an application that communicates with the firmware of a device. As there are changes to the firmware, it is versioned with the format `{major}.{minor}.{revision}[beta[{beta}]]`. To give you a few examples, the current version is `0.4.7beta` which will be followed by `0.4.7beta2` and occasionally `0.4.8`. The versioning format of the firmware is unfortunately not under my control, so I can not change it.

I need a way of comparing firmwares with each other. Basically, I need a function

    boolean isFirmwareNewer(String testFW, String baseFW);

What I did so far was to convert this format to a simple `int`. So `0.4.7beta2` will become `00040702` (2 digits for each level). The problem is, that

 1. My code is difficult to read (>40 lines and 3 methods)
 2. I am sure, there is a elegant solution to this (maybe using regex?)
 3. I want to have a wildcard `0.0.0` which is newer by definition

How do you guys do this normally (or how would you do it)?

If you want, I can attach the code I am currently working with, but as I said, it's >40 lines of code and not really readable (which is the reason why I am looking for a better way to do this).