pos()

Read(1124) 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

@w

Only locate a same and whole substring

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.

pos("aab,aa","aa")

1

pos@w("aab,aa","aa")

5; use @w option to locate the same and whole substring only.

pos@h("abcdef","abc",3)

1; use @h option to match the parent string from the beginning. That is, ignore parameter begin and search for the substring from the 1st character of parameter s1.