0

We have docker tags with below versions, please help to share the regex pattern to filter the records that are older than below values. For example, should show old tags - 23.0.0.17 and older, 23.0.0.17_acme.17.xxxxxxx and older, etc?

23.0.0.18
23.0.0.18_acme.18.xxxxxxx
23.1.0.11
23.1.0.11_acme.11.xxxxxxx
Destroy666
  • 12,350

1 Answers1

1

To get versions 23.0.0.17 or older, you could use this for JS:

^((23\.0\.0\.(1[0-7]|\d))|((2[0-2]|1\d|\d)\.\d+\.\d+\.\d+))\S*

As I said in comment below question, this is not really a job for regexes, although you can play around and build some. You basically have to consider all the options for digit combinations - the 1st alternative matches all possible 23 versions and the 2nd matches anything below.

A much better idea is to use libraries that are built to compare versions or write a function on your own,like https://stackoverflow.com/a/16187766/7264739

Destroy666
  • 12,350