Hi Peter,
If you're not a RegEx fan, this can be done easily with standard string operations. This assumes that there is one one-and-only-one occurrence of
CT, and one-and-only-one occurrence of
CW (both case insensitive, but you can make it case sensitive by adding
1 as the third parameter to the
InStr call):
Code: Select all
TestString:="fs14 ZY7 w190 h40 x865 y520 CW50595E CTE1E1E1"
CT6:=StringSplitThis(TestString,"CT")
CW6:=StringSplitThis(TestString,"CW")
MsgBox,4160,String Split Test,CT6=%CT6%`nCW6=%CW6%
ExitApp
StringSplitThis(Haystack,ID)
{
Return SubStr(Haystack,InStr(Haystack,ID)+2,6)
}
Note that the function works for any unique two-character ID (not just CT and CW) and for the ID to be in any position in the string. Regards, Joe