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
RegexReplace (Function)
In french: RegexRemplace
Replaces all the parts of a string that follow a specific format.
Example
// Replace all dates in DD/MM/YYYY format with dates in MM/DD/YYYY format
sString is string
sString = "The order will be delivered between 28/08/2020 and 02/09/2020."
 
sString = RegexReplace(sString, "([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})", "$2/$1/$3")
// sString contains "The order will be delivered between 08/28/2020 and 09/02/2020".
s is string = "aaa" + Charact(10) + "bbb" + Charact(13) + Charact(10) + ...
"ccc" + Charact(13) + Charact(10) + "ddd" + Charact(10) + "eee" + Charact(13) + "fff"
 
Trace(s)
 
s2 is string = RegexReplace(s, "(.*)([^\n])\r(.*)", "$1$2" + ...
Charact(13) + Charact(10) + "$3")
 
Trace(s2)
Syntax
<Result> = RegexReplace(<Initial string> , <Format> , <Replacement string>)
<Result>: Character string
String in which the replacements were made.
<Initial string>: Character string
String in which the replacements are to be made.
<Format>: Character string
Regular expression that indicates the format of the part of the string to be replaced.
<Replacement string>: Character string
String that will replace all the parts of the initial string that follow the given format.
Remarks
  • The specification used for regular expressions is ECMAScript.
  • You can retrieve a part of a string to use it in the replacement string (see example). In this case:
    • '$&' corresponds to the whole found string.
    • '$1' corresponds to the first part of the found string.
    • '$2' corresponds to the second part of the found string.
    • '$n' corresponds to the nth part of the found string.
Business / UI classification: Neutral code
Component: wd290std.dll
Minimum version required
  • Version 27
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help