Thanks very much to all of you who answered. You guys are awesome.
I chose Athanasius's answer and everything I anticipated yesterday worked with this solution but there are a few more use cases that came up.
Athanasius,
While I'm still learning, do you mind updating code for the following additional cases:
1)
Input: AB AL0024
Output with code provided: AB-
Desired output: AB-AL0024 (if the year is missing, then is it possible to add a dash?)
2)
Input: DRSVA 1994 K-2
Output with code provided: DRSVA94- K-2
Desired Output: DRSVA94-K-2 (spaces are not allowed in the output)
3) Input: PUN VALEY B
Output with code provided: PUN-VALEY B
Desired output: PUN-VALEYB (spaces are not allowed in the output)
4)Input: TIBET 2015
Output with code provided: TIBET15-
Desired output: TIBET15 (is it possible to avoid dashes if nothing follows it?)
The original cases were critical and these are special cases which will appear rarely if at all but I just wanted to code for it just in case. Let me know if this is possible.
Thanks