Left( [TEXTSTRING], Len( [TEXTSTRING] ) [position] )
!TEXTSTRING![:int(!position!)]
>>> a = 'this is out at pos 2' >>> b = 'out at pos 0' >>> c = 'pos 3 is out' >>> def findIndex(string, word): return string.split().index(word) >>> for test in [a, b, c]: print findIndex(test, 'out') 2 0 3
If using field calculator try this.!TEXTSTRING![:int(!position!)]
int() may or may not be required depending on field type of "position"
!TEXTSTRING!.split("out")[0].strip()
Do you mean splitting it up by white space and finding where the word 'out' is within a string? If so, you could get the position with something like this:>>> a = 'this is out at pos 2' >>> b = 'out at pos 0' >>> c = 'pos 3 is out' >>> def findIndex(string, word): return string.split().index(word) >>> for test in [a, b, c]: print findIndex(test, 'out') 2 0 3
I don't know much VB so I'm not sure what you're doing once you have the index?
EDIT: Matt's answer is waaaay better than mine.
If you are just looking to get everything before the word "out" in a text string, how about:!TEXTSTRING!.split("out")[0].strip()