PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | French EN
  • Search in an array: managing ambiguities
  • StringCount and UNICODE
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Calculates:
  • the number of occurrences of a specific character string (by respecting the search criteria) in another character string.
  • the number of occurrences of a set of strings in an array.
Versions 15 and later
Android This function is now available for Android applications.
New in version 15
Android This function is now available for Android applications.
Android This function is now available for Android applications.
Versions 17 and later
iPhone/iPad This function is now available for iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for iPhone/iPad applications.
iPhone/iPad This function is now available for iPhone/iPad applications.
Versions 18 and later
Android Widget This function is now available in Android Widget mode.
New in version 18
Android Widget This function is now available in Android Widget mode.
Android Widget This function is now available in Android Widget mode.
Versions 21 and later
Apple Watch This function is now available in Apple Watch mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Apple Watch This function is now available in Apple Watch mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Apple Watch This function is now available in Apple Watch mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Example
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:
WholeWordSearches for a whole word, i.e, a word enclosed in punctuation characters (characters other than a letter or a digit) or spaces.
WEBDEV - Browser code This constant is not available.
IgnoreCaseSearches 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:
WholeWordSearches for a whole word, i.e, a word enclosed in punctuation characters (characters other than a letter or a digit) or spaces.
WEBDEV - Browser code This constant is not available.
IgnoreCaseSearches 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.
See Managing UNICODE for more details.
Reminder: The linguistic parameters used are defined during the call to ChangeCharset.
Component : wd260vm.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment