I have a changelog that has the version numbers in square brackets like this:
## [0.3.0] - 2016-12-13
- FIX This is an example fix
- FEATURE An example feature
I want to extract only the version numbers so I am left with:
[Unreleased]
[0.3.0]
[0.2.4]
[0.2.3]
Ideally I'd like to extract only the first value in square brackets that isn't 'Unreleased' so I get the latest version number 0.3.0 although I'm not sure this is possible in regex.
Can anyone help? Thanks :)
You can use a regex like this:
With the replacement string:
\1
Btw, if you want to remove all the other text, then you can use:
Working demo
Update: if you want to transform the changelog in a list of versions, I could come up with this regex:
Working demo