Created
July 12, 2016 15:32
-
-
Save davidroberts63/c022db3856e5aad57cc430fdd0ab2753 to your computer and use it in GitHub Desktop.
SecondToLastIndexOf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Console.WriteLine("abedef".LastIndexOf("e","abedef".LastIndexOf("e")-1)); | |
// --> 2 | |
// Yes, a bit dirty, but if you use a regex then you'll have two problems. |
Unfortunately, SemVer 2 (inc. pre-release and metadata) makes it quite a bit more complex. For parsing e.g. acme.web.1.2.3-alpha.1.2+build
into a package name and version, I ended up with:
(?<packageId>(\w+([_.-]\w+)*?))\.(?<semanticVersion>(\d+(\.\d+){0,3}(-[0-9A-Za-z-]*(\.[0-9A-Za-z-]*)*)?)(\+[0-9A-Za-z-]*)?)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You want a regex? You may already have it but I've used this in our build process.
(?'major'\d+).(?'minor'\d+).(?'patch'\d+)