PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
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
StringSplit (Function)
In french: ChaîneDécoupe
Extracts all the sub-strings from a character string according to a one or more string separators.
Example
// Split a character string according to a separator
sCountry is string = "France, Portugal, Germany, Wales"
arrCountry is array of strings
arrCountry = StringSplit(sCountry, ", ")  
// Returns ["France","Portugal","Germany","Wales"]
// Split a character string according to a separator
sCountry is string = "France, Portugal, Germany, Wales"
sCountry1, sCountry2, sCountry3, sCountry4 are strings
// Use the multiple assignment
(sCountry1, sCountry2, sCountry3, sCountry4) = StringSplit(sCountry, ", ")
// sCountry1 is set to "France",  sCountry2 is set to "Portugal",
// sCountry3 is set to "Germany", sCountry4 is set to "Wales"
// Split a character string by using different separators between each sub-string
sMenu is string = "Starter Today's special, Dessert"
sStarter, sTodaysSpecial, sDessert are strings
// Use the multiple assignment
(sStarter, sTodaysSpecial, sDessert) = StringSplit(sMenu, " ", ", ")
// sStarter is set to "Starter",
// sTodaysSpecial is set to "Today's special",
// sDessert is set to "Dessert"
Syntax

Splitting a character string according to one or more separators Hide the details

<Result> = StringSplit(<Initial string> [, <Separator> [, <Options>]])
<Result>: Array of strings
Array containing the different sub-strings found between the separators.
<Initial string>: Character string (with quotes)
String to split (up to 2 GB).
<Separator>: Optional character string (with quotes)
Corresponds to:
  • The string used to delimit the sub-strings. This string is not included in the result. This separator is case sensitive.
  • An array of strings. The different strings found in the array are used to delimit the sub-strings. The separators are not included in the result. These separators are case sensitive.
If this parameter is not specified, the default separator is TAB.
<Options>: Optional Integer constant
Options for formatting sub-strings in the array containing the result:
ccUpCaseConverts the character string into uppercase characters (including the accented characters).
ccLowCaseConverts the character string into lowercase characters.
ccNormal
(default value)
No formatting is performed.
ccIgnoreAccentConverts the accented characters into non-accented characters.
ccIgnoreSpaceDeletes the following characters at the beginning and at the end of string:
  • space (character 32)
  • tabulation (character 9)
  • carriage return (character 13)
  • line break (character 10)
  • control characters 11 and 12
ccIgnorePunctuationAndSpaceRemoves the punctuation and the space characters.

Splitting a character string by using different separators for each sub-string Hide the details

<Result> = StringSplit(<Initial string> , <Separator 1> , <Separator 2> ... [, <Separator N>] [, <Options>])
<Result>: Array of character strings
Array containing the different sub-strings found between the separators.
<Initial string>: Character string (with quotes)
String to split (up to 2 GB).
<Separator 1>: Character string (with quotes)
Separator of sub-strings with subscript 1 and 2. This string is not included in the result. This separator is case sensitive.
<Separator 2>: Character string (with quotes)
Separator of sub-strings with subscript 2 and 3. This string is not included in the result. This separator is case sensitive.
<Separator N>: Character string (with quotes)
Separator of sub-strings with subscript N-1 and N. This string is not included in the result. This separator is case sensitive.
<Options>: Optional Integer constant
Options for formatting sub-strings in the array containing the result:
ccUpCaseConverts the character string into uppercase characters (including the accented characters).
ccLowCaseConverts the character string into lowercase characters.
ccNormal
(default value)
No formatting is performed.
ccIgnoreAccentConverts the accented characters into non-accented characters.
ccIgnoreSpaceDeletes the following characters at the beginning and at the end of string:
  • space (character 32)
  • tabulation (character 9)
  • carriage return (character 13)
  • line break (character 10)
  • control characters 11 and 12
ccIgnorePunctuationAndSpaceRemoves the punctuation and the space characters.
Component : wd240vm.dll
Minimum version required
  • Version 22
This page is also available for…
Comments
Video StringSplit
https://youtu.be/_ow6M_xDIT0

https://windevdesenvolvimento.blogspot.com/2019/05/dicas-2115-windev-webdev-mobile-string.html

// btn_stringsplit

sESTADOS_BRASIL is string=""
sESTADOS_BRASIL="AC|AL|AM|AP|BA|CE|ES|EX|GO|MA|MG|MS|MT|PA|PB|PE|PI|PR|RJ|RN|RO|RR|RS|SC|SE|SP|TO"
arrARRAY_ESTADOS_BRASIL is array of strings
arrARRAY_ESTADOS_BRASIL=StringSplit(sESTADOS_BRASIL,"|")
TableDeleteAll(TABLE_ESTADOS)
nQUANTIDADE_TOTAL is int=ArrayCount(arrARRAY_ESTADOS_BRASIL)
FOR NPOSICAO = 1 TO nQUANTIDADE_TOTAL
TableAddLine(TABLE_ESTADOS,arrARRAY_ESTADOS_BRASIL[NPOSICAO])
END

amarildo
19 May 2019