The Pos function returns the offset of the first occurrence of a target string within another string.
If the target string is not found, 0 is returned.
result = Pos( needle, haystack [, offset ] ) |
Examples:
say Pos( 'abra', 'abracadabra' ) -- shows: 1 say Pos( 'abra', 'abracadabra', 2 ) -- shows: 8 say Pos( 'adra', 'abracadabra' ) -- shows: 0 |
Note: some Rexx environments support an Index function. This function has the same behavior as the Pos function, but the first two arguments are reversed, i.e.:
result = index( haystack, needle [, offset ] ) |