Syntax
long pos( string source(.), string pattern(.) )
long rpos( string source(.), string pattern(.) )
Description
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.
Example
long posno
posno = pos("abcdabcd", "bcd") | posno contains 2
posno = rpos("abcdabcd", "bcd") | posno contains 6
Related Post:
long pos( string source(.), string pattern(.) )
long rpos( string source(.), string pattern(.) )
Description
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.
Example
long posno
posno = pos("abcdabcd", "bcd") | posno contains 2
posno = rpos("abcdabcd", "bcd") | posno contains 6
Related Post:
0 comments:
Post a Comment