ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / String functions
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
StringSplit (Function)
In french: ChaîneDécoupe
Extracts all the substrings from a character string based on 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 using different separators
// between each substring
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 based on one or more separators Hide the details

<Result> = StringSplit(<Initial string> [, <Separator> [, <Options>]])
<Result>: Array of strings
Array that contains the different substrings delimited by separators.
<Initial string>: Character string
String to split (up to 2 GB).
<Separator>: Optional character string
Corresponds to:
  • The string that delimits the substrings. This string is not included in the result. This separator is case sensitive.
  • An array of strings. The different strings in the array delimit the substrings. 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 substrings in the array containing the result:
ccIgnoreAccentConverts accented characters to non-accented characters.
ccIgnorePunctuationAndSpaceRemoves spaces and punctuation characters.
ccIgnoreSpaceDeletes the following characters at the beginning and at the end of the string:
  • space (character 32)
  • tab (character 9)
  • carriage return (character 13)
  • line feed (character 10)
  • control characters 11 and 12
ccLowCaseConverts the string to lowercase characters.
ccNormal
(default value)
No formatting is performed.
ccUpCaseConverts the string to uppercase characters (including accented characters).

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

<Result> = StringSplit(<Initial string> , <Separator 1> , <Separator 2> ... [, <Separator N>] [, <Options>])
<Result>: Array of character strings
Array that contains the different substrings delimited by separators.
<Initial string>: Character string
String to split (up to 2 GB).
<Separator 1>: Character string
Separator of substrings at index 1 and 2 in the result array. This string is not included in the result. This separator is case sensitive.
<Separator 2>: Character string
Separator of substrings at index 2 and 3 in the result array. This string is not included in the result. This separator is case sensitive.
<Separator N>: Character string
Separator of substrings at index N-1 and N in the result array. This string is not included in the result. This separator is case sensitive.
<Options>: Optional Integer constant
Options for formatting substrings in the array containing the result:
ccIgnoreAccentConverts accented characters to non-accented characters.
ccIgnorePunctuationAndSpaceRemoves spaces and punctuation characters.
ccIgnoreSpaceDeletes the following characters at the beginning and at the end of the string:
  • space (character 32)
  • tab (character 9)
  • carriage return (character 13)
  • line feed (character 10)
  • control characters 11 and 12
ccLowCaseConverts the string to lowercase characters.
ccNormal
(default value)
No formatting is performed.
ccUpCaseConverts the string to uppercase characters (including accented characters).
Business / UI classification: Neutral code
Component: wd290vm.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

Last update: 05/26/2022

Send a report | Local help