RewriteRule ^forum/
(.*)/
(.*)/
([0-9]+)-
(.*)$ showthread.php?$3-$4 [R=301,L]
(.*) will match anything.
([0-9]+) will only match numbers of any length.
Whenever there's a match, it will be stored inside of a variable. In this case $3 will be the third match, which is the part which checks for the number. Each part that I made red will be stored in a variable.
The first URL only contains 2 different variables each time, so we only have to extract 2 variables.
The second URL contains 4 different things in the URL which may not be unique, that's why we simply match it with (.*).
RewriteRules and regexes are quite a pain.