PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US

  • Note regarding the Browse syntax of sub-strings defined according to a separator
  • ExtractString function 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
Used to:
  • extract a sub-string from a character string according to a given string separator.
  • browse the sub-strings in a character string according to a given string separator.
Notes:
  • Browsing sub-strings is faster than extracting sub-strings.
  • You have the ability to use an array of separators. This allows you to use several different separators at the same time.
Some examples:
  • extract a data read in an external file,
  • extract the information returned by HListFile or by HListKey,
  • extract a data from a list containing different data on the same line.
Versions 15 and later
Android This function is now available for the Android applications.
New in version 15
Android This function is now available for the Android applications.
Android This function is now available for the Android applications.
Versions 16 and later
Universal Windows 10 App This function is now available for the Windows Phone applications.
New in version 16
Universal Windows 10 App This function is now available for the Windows Phone applications.
Universal Windows 10 App This function is now available for the Windows Phone applications.
Versions 17 and later
iPhone/iPad This function is now available for the iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for the iPhone/iPad applications.
iPhone/iPad This function is now available for the iPhone/iPad applications.
Versions 18 and later
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
New in version 18
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps 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
Country is string = "France, Italy, Germany, Spain"
ExtractString(Country, 1, ", ")   // Returns "France"
ExtractString(Country, 2, ", ")   // Returns "Italy"
ExtractString(Country, 3, ", ")   // Returns "Germany"
ExtractString(Country, 4, ", ")   // Returns "Spain"
ExtractString(Country, 5, ", ")   // Returns EOT
MyString is string = "Strawberry, Raspberry, Chocolate and Banana"
ExtractString(MyString, 1, [", " , "," , " and "]) // Returns "Strawberry"
ExtractString(MyString, 2, [", " , "," , " and "]) // Returns "Raspberry"
ExtractString(MyString, 3, [", " , "," , " and "]) // Returns "Chocolate"
ExtractString(MyString, 4, [", " , "," , " and "]) // Returns "Banana"
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget Windows MobileUniversal Windows 10 AppJavaPHPAjaxUser code (UMC)Stored procedures
// Browse all the sub-strings
Country is string = "France, Italy, Germany, Spain"
SubString is string = ExtractString(Country, firstRank, ", ")
WHILE SubString <> EOT
Trace(SubString) // Returns "France", "Italy", "Germany", "Spain"
SubString = ExtractString(Country, nextRank, ", ")
END
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget Windows MobileUniversal Windows 10 AppJavaUser code (UMC)Stored procedures
// Browse all the sub-strings
// The separators are found in an array
sString is string = "Strawberry, Raspberry<br>Lemon<br>Chocolate and Banana"
sResult is string = ExtractString(sString, firstRank, [", " , " and ", "<br>"])
WHILE sResult <> EOT
Trace(sResult)
sResult = ExtractString(sString, nextRank, [", " , " and ", "<br>"])
END
Syntax

Extracting a sub-string according to a string separator Hide the details

<Result> = ExtractString(<Initial String> , <Rank> [, <Separator> [, <Search Direction>]])
<Result>: Character string
Corresponds to:
  • The sub-string included between the separator whose rank is <Rank> - 1 and the separator whose rank is <Rank> if <Browse Direction> is not specified or if it is equal to FromBeginning.
  • The sub-string included between the separator whose rank is <Rank> - 1 and the separator whose rank is <Rank> from the end of the string if <Browse Direction> corresponds to FromEnd.
  • The entire <Initial String> if <Initial String> contains no <Separator> and if <Rank> is equal to 1.
  • The EOT constant if <Rank> is greater than the number of separators found in the string.
<Initial String>: Character string (with quotes)
Character string (up to 2 GB) containing the string to extract.
<Rank>: Integer
Order number of the separator. For example, if the separator is TAB and if <Rank> is equal to 2, the extracted string will be included between the first and the second TAB.
<Separator>: Optional character string (with quotes) or optional array of strings
This parameter can correspond 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.
Versions 16 and later
PHP You now have the ability to use an array of strings.
New in version 16
PHP You now have the ability to use an array of strings.
PHP You now have the ability to use an array of strings.
<Search Direction>: Optional constant
Direction in which the search is performed:
FromBeginning
(Default value)
Search performed from the first character of the string to the last one
FromEndSearch performed from the last character of the string to the first one
WINDEVWEBDEV - Server codeWEBDEV - Browser codeReports and QueriesAndroidAndroid Widget iPhone/iPadApple WatchWindows MobileUniversal Windows 10 AppJavaPHPAjaxUser code (UMC)Stored procedures

Browsing the sub-strings according to a separator Hide the details

<Result> = ExtractString(<Initial String> , <Search Options> [, <Separator>])
<Result>: Character string
Corresponds to:
  • the next or previous sub-string according to the selected browse. <Result> does not contain the separator.
  • the EOT constant at the end of the browse.
<Initial String>: Character string (with quotes)
Character string (up to 2 GB) containing the string to extract.
<Search Options>: Integer constant
Direction in which the search is performed:
lastRankStarts browsing the sub-strings separated by the specified separator from the end of the string.
previousRankResumes a browse operation started by the lastRank constant
firstRankStarts browsing the sub-strings separated by the specified separator from the beginning of the string.
nextRankResumes a browse operation started by the firstRank constant
<Separator>: Optional character string (with quotes) or optional array of strings
This parameter can correspond 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.
Versions 16 and later
PHP You now have the ability to use an array of strings.
New in version 16
PHP You now have the ability to use an array of strings.
PHP You now have the ability to use an array of strings.
Remarks

Note regarding the Browse syntax of sub-strings defined according to a separator

  • This type of browse operates on the constant strings only. Therefore, a project element (variable, control, item, ...) must necessarily be used as initial string.
  • When a browse is started with the firstRank or lastRank constants, the browse information is stored in memory as long as all the extracted sub-strings have not been browsed. Therefore, this type of browse should be used only when all the sub-strings must be processed.

ExtractString function and UNICODE

<Initial String> and <Separator> can both correspond to:
  • ANSI strings.
  • UNICODE strings.
  • buffers.
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):
  • It at least one of the strings is a buffer, all the strings are converted into buffers and the operation is performed with buffers,
  • otherwise, if at least one of the strings is in Unicode format, all the strings are converted into Unicode and the operation is performed in Unicode,
  • otherwise, the operation is performed in Ansi format.
The following conversion rule is used for the Unicode systems (Windows CE):
  • It at least one of the strings is a buffer, all the strings are converted into buffers and the operation is performed with buffers,
  • otherwise, the operation is performed in Unicode.
Note: If the result on an ANSI string is assigned to a UNICODE string (and conversely), the conversion will be implicitly performed.
See Managing the UNICODE format for more details.
Related Examples:
The standard functions on strings Unit examples (WINDEV): The standard functions on strings
[ + ] Using the main functions for handling character strings:
- Position and PositionOccurrence
- Replace
- StringBuild
- Left, Right, Middle
- ExtractString
Components
WINDEVWEBDEV - Server codeReports and Queries wd230vm.dll
Windows Mobile wp230vm.dll
WEBDEV - Browser code WDJS.DLL
Java wd230java.jar
Linux wd230vm.so
Android wd230android.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
Outro Exemplo ExtractString
SELECT
cliente.nome AS nome,
cliente.clienteID AS clienteID,
cliente.email AS cliente_email,
WL.ExtractString(cliente.email,1,'@') AS o1,
WL.ExtractString(cliente.email,2,'@') AS _dominio
FROM
cliente

// WL.ExtraitChaîne => wl.extractString
// amarildo@matosinformatica.com.br
// 1,= amarildo
// 2,= matosinformatica.com.br

//Blog com Video e exemplo
http://windevdesenvolvimento.blogspot.com.br/2016/01/windev-sql-17-sql-select-wlextractstring.html
De matos AMARILDO
Jan. 16 2016
Outro Exemplo extractString Dentro Banco
//Blog com exemplo ExtractString dentro do Banco Dados

http://windevdesenvolvimento.blogspot.com.br/2016/01/windev-21-027-analise-tabela-formula.html
De matos AMARILDO
Jan. 16 2016
Exemplo ExtractString
SAI_TEXTO="SELECT * FROM TESTE"
SAI_RESULTADO_ANTES=ExtractString(SAI_TextO,1,"FROM",FromBeginning)
SAI_RESULTADO_DEPOIS=ExtractString(SAI_TextO,1,"FROM",FromEnd)
SAI_RESULTADO_ANTES="SELECT * FROM"
SAI_RESULTADO_DEPOIS="TESTE"

//-- BLOG COM VIDEO
http://windevdesenvolvimento.blogspot.com.br/2016/01/windev21-curso-219-extractstring-separa.html
De matos AMARILDO
Jan. 11 2016