I have thousands of mapping pattern that I need to convert. Attached is the image which shows the source value which I need to convert into Target values.
Few of the rules that I am able to decipher are below: -
I am looking at ways to convert the source values into intended target values using any software possible.
This quick user defined function appears to meet your requirements without regular expressions.
Function mapSource(str As String)
Dim tmp As Variant, i As Long
'strip leading hyphens
Do While Left(str, 1) = Chr(45) And Len(str) > 0: str = Right(str, Len(str) - 1): Loop
'split str to a maximum of 8 array elements
tmp = Split(str, Chr(45), 8)
'preserve an array of 8 elements
ReDim Preserve tmp(7)
'replace empty array elements with hyphens
For i = LBound(tmp) To UBound(tmp)
If tmp(i) = vbNullString Then tmp(i) = Chr(45)
Next i
'rejoin array into str
str = Join(tmp, Chr(124))
'output mapped str
mapSource = str
End Function