Hi,
I need to substitute from one string to another in perl:
Here are 4 examples that handle all my use cases:
1)
From: 'GNRABS 2014-186'
To: 'GNRABS14-186'
2)
From: 'A10 2013-1'
To: 'A1013-1'
3)
From: 'CGBAM 2014-HD'
To: 'CGBAM14-HD'
4)
From: 'FHMS K032'
To: 'FHMS-K032'
Description:
1) The first part (before space) is just any number of characters and I need to use it as is
2) Second part starts after space and is the year I need to strip from 4 chars to 2 (as per first 3 examples) . Or skip if it doesn’t exist like example 4
3) The third part is what is remaining (including dash like all first 3 examples), but you always need a dash even if it doesn’t exist in the original string like examples 4
Can you recommend what code I need to use for this type of conversion from one string to another