Finding Character Position in String
Keywords: find locate itemlocate string functions
Question:
Is it possible to use ItemLocate to find the position of a particular character in a string, and then select the two characters to the left of the located character?
Answer:
Umm. No. This would require use of the string functions. Something like:
DaString="ABCQXYZ" DaChar="Q" a=StrIndex(DaString,DaChar,0,@FWDSCAN) DaAnswer=StrSub(DaString,a-2,2)More examples:
I'm interested in is some string manipulation tools, such as StrRight, StrLeft, StrMid, i.e be able to ask for the left 5 char's from a string, or from the right, or even say for the 6 chars 3rd from the left.Here's an example using the StrSub function:
- Left 5 chars:
newstring=strsub(oldstring,1,5)- Right 5 chars:
newstring=strsub(oldstring, strlen(oldstring)-5,5)- 6 chars 3rd from left:
newstring=strsub(oldstring,3,6)
Article ID: W13333Filename: Finding Character Position in String.txt