- Search in an array: managing ambiguities
- StringCount and UNICODE
StringCount (Function) In french: ChaîneOccurrence
Res = StringCount("anastasia", "a") // Returns 4 Res = StringCount("toto titi tito", "to") // Returns 3 Res = StringCount("toaster", "X") // Returns 0 Res = StringCount("An Indian hunts an eagle", "an") // returns 2 Res = StringCount("An Indian hunts an eagle", "an", WholeWord) // returns 1 Res = StringCount("An Indian hunts an eagle", "an", IgnoreCase) // Returns 3 Res = StringCount("An Indian hunts an eagle", "an", IgnoreCase + WholeWord) // Returns 2
Res = StringCount("anastasia", ["a","s"]) // Returns 6
Syntax
Number of occurrences of a character string Hide the details
<Result> = StringCount(<Initial string> , <Search string> [, <Options>])
<Result>: Integer - Number of occurrences,
- 0 if no occurrence exists or if <Search string> corresponds to an an empty string ("").
<Initial string>: Character string (with quotes) Text in which the occurrences of <Search string> must be found. <Search string>: Character string (with quotes) Text to find in <Initial string>. <Options>: Optional constant (or combination of constants) Search options: | | WholeWord | Searches for a whole word, i.e, a word enclosed in punctuation characters (characters other than a letter or a digit) or spaces.
| IgnoreCase | Searches ignoring the case (uppercase/lowercase characters) |
Number of occurrences of strings in an array Hide the details
<Result> = StringCount(<Initial string> , <Array of search strings> [, <Options>])
<Result>: Integer - Number of occurrences,
- 0 if there are no occurrences or if <Array of search strings> contains empty strings ("").
<Initial string>: Character string (with quotes) Text in which the occurrences of <Search string> must be found. <Array of search strings>: Array Name of the array that contains the strings to be found in the <Initial string>. <Options>: Optional constant (or combination of constants) Search options: | | WholeWord | Searches for a whole word, i.e, a word enclosed in punctuation characters (characters other than a letter or a digit) or spaces.
| IgnoreCase | Searches ignoring the case (uppercase/lowercase characters) |
Remarks Search in an array: managing ambiguities When the search strings are substrings of other strings in the array, the longest strings are taken into account. Example: If the ["after", "afternoon", "afterward"] array of strings must be found in "Come this afternoon after the game", the first occurrence found will be "afternoon" (and not "after"). StringCount and UNICODE You have the ability to use ANSI strings, Unicode strings and buffers in the different parameters of the function. The following conversion rule is used for the Ansi systems (Windows or Linux): - If at least one of the strings is a buffer, all the strings are converted to buffers and the operation is performed with buffers.
- If the first condition is not met and there is at least one Unicode string, all the strings are converted to Unicode and the operation is performed in Unicode (the conversion is performed with the current character set, if necessary).
- Otherwise, the operation is performed in Ansi.
The following conversion rule is used for the Unicode systems (Windows CE): - If at least one of the strings is a buffer, all the strings are converted to buffers and the operation is performed with buffers.
- Otherwise, the operation is performed in Unicode.
Reminder: The linguistic parameters used are defined during the call to ChangeCharset.
This page is also available for…
|
|
|