Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Regex – greater than specific release version

I need to make Regex expression which will take into account only versions greater than release version release/2022.2.1
So that version should be excluded, along with all previous (2022.1.1, 2021.4.1 etc.)
The first version that I would like to include will be release/2022.2.2 and any after that.
So I made a regex:

^release/2022.[2-9].[2-9]|release/2023.[\d].[\d]

And this works!
But this will mean that for every year I need to add | and after that years that are coming (2024, 2025... etc.)

Obviously this is not an optimal way. How to optimize this?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thanks!!!

>Solution :

If you need a regex for all upcoming versions in this format until 2099, take

^release\/20(22\.(2\.[2-9]|[3-9]\.\d)|(2[3-9]|[3-9]\d)\.[\d]\.[\d])
  • ^release\/20 – fix part
  • 22\.(2\.[2-9]|[3-9]\.\d) – all values from 22.2.3 to 22.9.9
  • (2\.[3-9]|[3-9]\d) – years 23-29 or 30-99
  • year 23-99 \.[\d]\.[\d] – all versions, .0.0 to .9.9

You can see a more detailed explanation of what’s what here

I still recommend against using regex and use any other language

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading