- Finding the character string
- Unicode/Ansi
- Characters taken into account for the punctuation and the spaces
- Various
Position (Function) In french: Position
n is int MyString is string = "What a wonderful World" n = Position(MyString, "won", 1, FromBeginning) // Returns 8 (position of "w" in "wonderful") n = Position(MyString, "XXX") // Returns 0 (no "XXX" found in the string) n = Position(MyString, "l", 0, FromEnd) // Returns 21 (position of "l" in "World") n = Position(MyString, "e", 11) // Returns 12 (position of "e" in "wonderful") n = Position(MyString, "o", Length(MyString), FromEnd) // Returns 19 (position of "o" in "World") n = Position(MyString, "o", n-1, FromEnd) // Returns 9 (position of "o" in "wonderful") n = Position(MyString, "o", n-1, FromEnd) // Returns 0 (there is no other "o")
n is int MyString2 is string = "http://Server/File.html" n = Position(MyString2,["/","//"]) // Returns 6 n = Position(MyString2,["/","//"], 8) // Returns 15
Syntax
Finding a character string Hide the details
<Result> = Position(<Initial String> , <String to Find> [, <Start Position> [, <Option>]])
<Result>: Integer - Position of first character of character string sought in the initial string,
- 0 if the sought string is not found.
This position is given in relation to the beginning of string.
<Initial String>: Character string Character string where the search will be performed (maximum size: 2 GB). <String to Find>: Character string Character string that must be found in the initial string. <Start Position>: Optional integer Subscript of character from which the search will be performed. By default, the search starts from the first character (character 1). To perform a search from the end of the string (FromEnd constant), this parameter must correspond to 0 or to the size of the string. If this parameter is negative, the search starts from the first character. If this parameter is greater than the number of character found in <Initial String>, <Result> is equal to 0. <Option>: Optional constant (or combination of constants) Indicates the search direction and the characteristics of the search: | | FromBeginning (Default value) | Search performed from the first character of the string to the last one | FromEnd | Search performed from the last character of the string to the first one | WholeWord | Search for the whole word, which means enclosed in punctuation characters or in space characters | IgnoreCase | Search while ignoring the case (uppercase/lowercase) or the accented characters |
Versions 16 and later New in version 16Remarks Various PositionOccurrence is used to find out the position of Nth occurrence of sub-string by performing a search from the beginning of string or from the end of string.
This page is also available for…
|
|
|