<p>I have a version number of the following form:</p>

<p>version.release.modification</p>

<p>where version, release and modification are either a set of digits or the '*' wildcard character. Additionally, any of these numbers (and any preceding .) may be missing.</p>

<p>So the following are valid and parse as:</p>

<pre><code>1.23.456 = version 1, release 23, modification 456
1.23     = version 1, release 23, any modification
1.23.*   = version 1, release 23, any modification
1.*      = version 1, any release, any modification
1        = version 1, any release, any modification
*        = any version, any release, any modification
</code></pre>

<p>But these are not valid:</p>

<pre><code>*.12
*123.1
12*
12.*.34
</code></pre>

<p>Can anyone provide me a not-too-complex regex to validate and retrieve the release, version and modification numbers?</p>

This might work:
```
```
^(\*|\d+(\.\d+){0,2}(\.\*)?)$
```
```
At the top level, "*" is a special case of a valid version number. Otherwise, it starts with a number. Then there are zero, one, or two ".nn" sequences, followed by an optional ".*". This regex would accept 1.2.3.* which may or may not be permitted in your application.
The code for retrieving the matched sequences, especially the
```
(\.\d+){0,2}
```
part, will depend on your particular regex library.