WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: stevengraff on February 18, 2014, 02:22:22 PM

Title: Parsing a name from mid-string
Post by: stevengraff on February 18, 2014, 02:22:22 PM
I have a string from which I need to get the name out of the middle:

numselected = "Additional, Sally Jackson : (248)111-8888 (Ph) Ms. Jackson "

I'm using:

     colonLoc = strIndex( numselected, " :", 1, @Fwdscan )
     commaLoc = strIndex( numselected, "," ,1, @fwdscan)
     fullName = strSub( numselected, commaloc + 2, colonLoc - commaLoc - 2 )

which works, but... I'm wondering if there isn't some much simpler way. Any ideas?
Title: Re: Parsing a name from mid-string
Post by: stanl on February 18, 2014, 02:45:44 PM
I doubt it is simpler, or even faster... but

Code (WINBATCH) Select

n = "Additional, Sally Jackson : (248)111-8888 (Ph) Ms. Jackson "
n1 =StrTrim(ItemExtract(1,ItemExtract(2,n,","),":"))
Message("",n1)
Title: Re: Parsing a name from mid-string
Post by: stevengraff on February 18, 2014, 03:56:19 PM
Thanks.