pos()

Read(764) Label: parent string, substring, position,

Description:

Get the position of a substring in its parent string.

Syntax:

pos(s1, s2{, begin})

Note:

The function finds the position of substring s2 in the parent string s1, which starts from the position begin, and returns null if the substring cannot be found.

Parameter:

s1

The parent string where you want to search for a substring

s2

Substring of interest

begin

The position from which the search starts; the default search is from the beginning

Option:

@z

Perform the search leftward starting from begin, while the search will be done rightward by default

@c

Case-insensitive

@h

Search for the substring at the beginning of the parent string by ignoring parameter begin

@q

Skip quoted strings when searching the parent string

Return value:

Integer type

Example:

pos("abcdef","def")

4

pos("abcdefdef","def",5)

7

pos("abcdef","defa")

(null)

pos@z("abcdeffdef","def",7)

4

pos("abcdeffdef","def",7)

8

pos@c("abcdef","Def")

4; @c option makes case-insensitive.

pos ("a'b'cbe","b")

3

pos@q("a'b'cbe","b")

6; use @q option to skip quoted strings.