Preg Replace is a very useful function made for replacing a matching string with a certain replacing string.
It can easily be used to remove clutter that you don't need, but it can also be used for advanced replacing applications, like correctly replacing version numbers in a changelog.
$messageToReplace = preg_replace( '/.*\/*\s\w*\sfrom\s([a-z]\d*\.\d*\.\d*\s|\d*\.\d*\.\d*\s)/', '', $matchingMessage ); $separatedChangelog[$key] = preg_replace( '/to\s([a-z]\d*\.\d*\.\d*\s(patch|minor|major))|to\s(\d*\.\d*\.\d*\s(patch|minor|major))|to\sdev-.*/', $messageToReplace[array_keys($messageToReplace)[0]], $change );
This first uses preg_replace to remove all of that message that it doesn't need, making it the string to replace the next part.