Well, here is the finished product. Its quite ugly. But your structure is what get this working, finally!
What this actually does is to take a range of numbers, i.e. "1034, 1040-1045, 1088, 1090" to "1034,1040,1041,1042,1043,1044,1045,1088,1090".
It also takes into account when the number has an alpha prefix, such as "VR1010-1013, 1044," converts to: "VR1010,VR1011,VR1012,VR1013,VR1044" It also allows for exceptions when VR is not at the prefix of the other numbers. It also accounts for spaces between the alpha prefix and the number, i.e. "VR 1010-VR1013" etc.
Thanks much.
ClearCollect(
DataItems,
With({_items: FirstN(Filter(temporary_assign_wo, Updated<>3), IfError(Value(TextInput6.Text),0))},
ForAll(_items As _item,
With({_sn: Substitute(_item._SNValve, ";", ",")},
With({_SN_Prefix: Trim(Left(_sn,
Max(
ForAll(Sequence(Len(First(Split(First(Split(_sn,",").Result).Result,"-").Result).Result),1,1).Value,
If(IsNumeric(Mid(First(Split(First(Split(_sn,",").Result).Result,"-").Result).Result,Value,1))=false
,Value)).Value,
Value)
)
)},
Patch(_item,{_SNValveFixed: _sn,
_TestUseLast: "Test" & _sn,
Index: _item.Index,
SN_Prefix: _SN_Prefix,
SN_List: Match(
Concat(
ForAll(
TrimEnds(
Split(_sn,",")).Result,
If(
IsBlank(Find("-",ThisRecord.Result)),
ThisRecord.Result,
If(_SN_Prefix="",
Match(Concat(
Sequence(Value(Last(Split(ThisRecord.Result,"-").Result).Result)
-Value(First(Split(ThisRecord.Result,"-").Result).Result)+1,
Value(First(Split(ThisRecord.Result,"-").Result).Result),1).Value,
Concatenate(Text(Value),",")
),
"^(?<trim>.*),$"
).trim,
Match(Concat(
Sequence(Value(Last(Split(Last(Split(ThisRecord.Result,"-").Result).Result,_SN_Prefix)).Result)
-Value(Last(Split(First(Split(ThisRecord.Result,"-").Result).Result,_SN_Prefix)).Result)+1,
Value(Last(Split(First(Split(ThisRecord.Result,"-").Result).Result,_SN_Prefix)).Result),1).Value,
Concatenate(_SN_Prefix,Text(Value),",")
),
"^(?<trim>.*),$"
).trim
))
),
Concatenate(Value,",")
),
"^(?<trim>.*),$"
).trim
})
))))
)