Version regular expression in CMake

eraxillan

I want to validate user-specified version string - to ensure it consists of three period-separated numbers (e.g. 1.20.300).
But i'm not sure how to write such regex, the code below is just a try:

if( PROJECT_VERSION MATCHES "([0-9]+).([0-9]+).([0-9+])" )
    message( "NOTE: Valid version string" )
else()
    message( FATAL_ERROR "Invalid version string" )
endif()

So, how to correctly write required regex?
Thanks.

UPD
My regex also matches 1.2.3.4, but is should not!
Only three period-separated numbers are possible.

John Zwinck

Dots are special in regex, so you should escape them:

"^([0-9]+)\\.([0-9]+)\\.([0-9]+)$"

Why double-backslash? See here: https://stackoverflow.com/a/4490920/4323

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Version regular expression in CMake

From Dev

Regular expression in CMake install command

From Dev

cmake - error in compile regular expression

From Dev

PASS_REGULAR_EXPRESSION in CMake

From Dev

A more concise version of this Regular Expression?

From Dev

regular expression convert version wrong

From Dev

Regular expression to match version numbers

From Dev

replace Regular Expression by a modified version of the Regular Expression result

From Dev

replace Regular Expression by a modified version of the Regular Expression result

From Dev

Extract version from string with Regular Expression and lookahead

From Dev

Extract version from string with Regular Expression and lookahead

From Dev

bash + regular expression + capture java version

From Dev

Best way to get split version number with regular expression

From Dev

Regular expression to extract software version from the given text?

From Dev

Regular Expression for validatin version numbers using asp RegularExpressionValidator control

From Dev

Using regular expression to get latest pip package version

From Dev

Is this regular expression?

From Dev

Regular expression with?

From Dev

Regular expression for && and &

From Dev

Is there a regular expression for this?

From Dev

Regular expression for && and &

From Dev

regular expression

From Dev

AND in Regular expression

From Dev

Regular Expression

From Dev

Python: Combining regular expression groups into one inside a non-grouping version of regular parentheses

From Dev

Regular expression for arithmetic expression

From Dev

How can CMake's PASS_REGULAR_EXPRESSION match multiple lines of output?

From Dev

Regular expression to escape regular expressions

From Dev

Regular Expression to define a Regular Language

Related Related

  1. 1

    Version regular expression in CMake

  2. 2

    Regular expression in CMake install command

  3. 3

    cmake - error in compile regular expression

  4. 4

    PASS_REGULAR_EXPRESSION in CMake

  5. 5

    A more concise version of this Regular Expression?

  6. 6

    regular expression convert version wrong

  7. 7

    Regular expression to match version numbers

  8. 8

    replace Regular Expression by a modified version of the Regular Expression result

  9. 9

    replace Regular Expression by a modified version of the Regular Expression result

  10. 10

    Extract version from string with Regular Expression and lookahead

  11. 11

    Extract version from string with Regular Expression and lookahead

  12. 12

    bash + regular expression + capture java version

  13. 13

    Best way to get split version number with regular expression

  14. 14

    Regular expression to extract software version from the given text?

  15. 15

    Regular Expression for validatin version numbers using asp RegularExpressionValidator control

  16. 16

    Using regular expression to get latest pip package version

  17. 17

    Is this regular expression?

  18. 18

    Regular expression with?

  19. 19

    Regular expression for && and &

  20. 20

    Is there a regular expression for this?

  21. 21

    Regular expression for && and &

  22. 22

    regular expression

  23. 23

    AND in Regular expression

  24. 24

    Regular Expression

  25. 25

    Python: Combining regular expression groups into one inside a non-grouping version of regular parentheses

  26. 26

    Regular expression for arithmetic expression

  27. 27

    How can CMake's PASS_REGULAR_EXPRESSION match multiple lines of output?

  28. 28

    Regular expression to escape regular expressions

  29. 29

    Regular Expression to define a Regular Language

HotTag

Archive