pos() and rpos()

long pos( string source(.), string pattern(.) )
long rpos( string source(.), string pattern(.) )

These return the start position of a specified substring (pattern) in a specified string (source). source and pattern can be either strings or string expressions. 
pos() starts searching for the substring at the first position in the source string. rpos() starts searching at the last position in the source string. Both return the start position relative to the beginning of the source string. 

Return values
The start position of the substring in the string. Or 0 if the substring is not found. 

long posno
posno = pos("abcdabcd", "bcd")    | posno contains 2
posno = rpos("abcdabcd", "bcd")   | posno contains 6

Related Post:

People who read this post also read :


Post a Comment


Twitter Delicious Facebook Digg Stumbleupon Favorites More