-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide example RegEx #16
Comments
And now with corrected tags: ^v?(?P<major>\d+)\.(?P<minor>\d+)\.?P<patchlevel>\d+)~?(?P<special>[a-z]\w+[\d+])?$ |
So I guess Python doesn't use PCRE, does it? protected static final Pattern special_pattern = Pattern.compile("[A-Za-z][0-9A-Za-z-]*"); protected static final Pattern semver_pattern = Pattern.compile("v?(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?([A-Za-z][0-9A-Za-z-]*)?"); This expression also accepts version numbers with the minor and/or patch number omitted, e.g. "1.2" or "1alpha". |
I think it does. What you get from my regex is a dictionairy (key/value pairs) where the keys are "major", "minor", "patchlevel", "special" so that you can access the different parts by name and not by index from the regex grouping. |
@serverhorror your regex doesn't adhere to rule 3 properly. Something like The rule doesn't explicitly declare it, but it seems odd to allow a trailing dash ( |
I think this is outside the scope of SemVer. The spec should state the requirements clearly enough to easily construct a RegEx, and if it does not then that is a failure of the spec and should be addressed separately. |
I know this is old, but would it be beneficial to have "examples" enough to that implementation builders have test cases? |
Given that regex is available in all? languages mentioning the best known dialects and corresponding regular expressions to match would be nice:
Python 2.x:
The text was updated successfully, but these errors were encountered: