|
|
|
|
|
- Finding a character string
- Managing ambiguities
- PositionOccurrence and Unicode
PositionOccurrence (Function) In french: PositionOccurrence Finds the Xth position of a string within another string. You can also examine all positions of a substring within a string. It is also possible to find the Xth position of one of the strings in an array. n = PositionOccurrence("Antananarivo, Madagascar", "g", 1)
n = PositionOccurrence("Antananarivo, Madagascar", "zen", 1)
n = PositionOccurrence("Antananarivo, Madagascar", "n", 1)
n = PositionOccurrence("Antananarivo, Madagascar", "n", 2)
n = PositionOccurrence("Antananarivo, Madagascar", "a", 3, FromEnd)
n = PositionOccurrence("Antananarivo, Madagascar", ["an", "ar"], 1)
n = PositionOccurrence("Antananarivo, Madagascar", ["an", "ar"], 2)
n = PositionOccurrence("Antananarivo, Madagascar", ["an", "ar"], 3)
n = PositionOccurrence("Antananarivo, Madagascar", ["an", "ar"], 4)
MyString is string = "Antananarivo, Madagascar"
MyPosition is int = PositionOccurrence(MyString, "a", firstRank, IgnoreCase)
WHILE MyPosition <> 0
Trace(MyPosition)
MyPosition = PositionOccurrence(MyString, "a", nextRank, IgnoreCase)
END
MyString is string = "Antananarivo, Madagascar"
MyPosition is int = PositionOccurrence(MyString, ["a", "r"], firstRank, IgnoreCase)
WHILE MyPosition <> 0
Trace(MyPosition)
MyPosition = PositionOccurrence(MyString, ["a", "r"], nextRank, IgnoreCase)
END
MyString is string = "Antananarivo, Madagascar"
MyArray is array of 2 strings
ArrayAdd(MyArray, "an")
ArrayAdd(MyArray, "ar")
MyPosition is int = PositionOccurrence(MyString, MyArray, firstRank, IgnoreCase)
WHILE MyPosition <> 0
Trace(MyPosition)
MyPosition = PositionOccurrence(MyString, MyArray, nextRank, IgnoreCase)
END
Syntax
Finding the position of a substring within a string Hide the details
<Result> = PositionOccurrence(<Initial string> , <Search string> , <Index of occurrence to search for> [, <Search options>])
<Result>: Integer If <Search string> is a character string, the result is the position of the first character of the occurrence to search for in the initial string or 0 if the search string is not found.If <Search string> is an array of character strings, the result is the position of the first character of the first string found from the array of strings or 0 if no string from the array was found. <Initial string>: Character string Character string to be searched (maximum size: 2 GB). <Search string>: String or Array of strings This parameter can correspond to:- The string to be searched for in the initial string.
- An array of strings to be searched for in the initial string.
<Index of occurrence to search for>: Integer Number of the occurrence of <Search string>. <Result> will contain the position of this occurrence. If this parameter is less than 1, <Result> is set to 0. If the value of this parameter is greater than the number of characters in <Initial string>, <Result> is equal to 0. <Search options>: Optional constant Indicates the search direction and the search options: | | FromBeginning (Default value) | Searches from the first to the last character of the string | FromEnd | Searches from the last to the first character of the string | IgnoreCase | Case and accent insensitive search (ignores uppercase/lowercase differences) | WholeWord | Searches for a whole word (enclosed in punctuation characters or spaces) |
Examining the positions of a substring in a string Hide the details
<Result> = PositionOccurrence(<Initial string> , <Search string> , <Browse options> [, <Search options>])
<Result>: Integer If <Search string> is a character string, the result is the position of the first occurrence (depending on the search direction) in the initial string or 0 when the search has been completed.If <Search string> is an array of strings, the result is the position of the first character of the previous or next occurrence (depending on the search direction) in the array of strings or 0 if the search has been completed. <Initial string>: Character string Character string to be searched (maximum size: 2 GB). <Search string>: String or Array of strings This parameter can correspond to:- The string to be searched for in the initial string.
- An array of strings to be searched for in the initial string.
<Browse options>: Integer constant Browse direction: | | firstRank | Starts searching for substrings separated by the specified <Search string> from the beginning of the string. | lastRank | Starts searching for substrings separated by the specified <Search string> from the end of the string. | nextRank | Continues the search started with firstRank | previousRank | Continues the search started with lastRank |
<Search options>: Optional constant Indicates the search direction and the search options: | | FromBeginning (Default value) | Searches from the first to the last character of the string | FromEnd | Searches from the last to the first character of the string | IgnoreCase | Case insensitive search (ignores uppercase/lowercase differences). | WholeWord | Searches for a whole word (enclosed in punctuation characters or spaces) |
Remarks Finding a character string By default, the search is case sensitive: the searched string must have the same case as the string to be found in the string.. To perform a case-insensitive search, use the IgnoreCase constant. When the search strings are substrings of other strings in the array, the longest strings are taken into account. Example: If the string array ["bon", "bonjour", "bonsoir "] is to be searched in "Bien le bonjour mon bon monsieur", the first occurrence found will be "bonjour" (not "bon").
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|