getLatestChangelog method
Implementation
String getLatestChangelog(String changelog) {
final regex = RegExp(
r'(#+)(\s+)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?');
final match = regex.allMatches(changelog).take(2).toList();
if (match.length == 2) {
return changelog
.substring(match[0].start, match[1].start)
.replaceAll(regex, '')
.trim();
} else {
return changelog.replaceAll(regex, '').trim();
}
}