ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / String functions
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Checks whether a string matches the format defined by a regular expression. The different substrings that make up the format can be retrieved.
The specification used for regular expressions is ECMAScript.
New in version 2025
Android This function is now available for Android applications.
Android Widget This function is now available in Android widget mode.
WEBDEV - Browser code This function is now available in browser code.
Example
TXT_Result is string
// Define the string to be tested and the format it should match
sString is string = "28/03/2003"
sDateFormat is string = "([0-9]+)/([0-9]+)/([0-9]+)"
// Variables used to retrieve the different parts of the format
sDay is string
sMonth is string
sYear is string
// If the string matches the format, its different parts are displayed
IF sString.RegexMatch(sDateFormat, sDay, sMonth, sYear) THEN
 	TXT_Result = "Days: " + sDay
 	TXT_Result += CR + "Month: " + sMonth
 	TXT_Result += CR + "Year: " + sYear
 END
MyEmail is TO string = "monemail@provider.com"
// Email: check email validity
IF MyEmail.RegexMatch("^((?!\.)[\w\-_.]*[^.])(@\w+)(\.\w+(\.\w+)?[^.\W])$") THEN
	Trace("The email is syntactically correct.")
END
APassword is TO string = "Password$1".
// Password: check password complexity
IF Password.RegexMatch("^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[^\w\s]).{8,}$") THEN
	Trace("The password is strong.")
	// The string contains: 
	// * At least 8 characters, at least 1 digit
	// * At least 1 uppercase, at least 1 lowercase
	// * At least 1 special character
END
MyChain is TO string = "1.618033"
// Number: check whether the string contains a number
IF MyString.RegexMatch("[-+]?[0-9]*\.?[0-9]*") THEN
	Trace("The string is an integer or decimal.")
END
AddressIP is TO string
IPAddress = "192.168.100.1"
// IP address verification
IF AdresseIP.RegexMatch("^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$") THEN
	Trace("The string is an IP address.")
END
Syntax

Checking a format and retrieving the elements that match the format Hide the details

<Result> = <Element to check>.RegexMatch(<Format> [, <Variable 1> [... [, <Variable N>]]])
<Result>: Boolean
  • True if the string matches the specified format,
  • False if the string does not match the format.
<Element to check>: ANSI string variable
Character string to check.
<Format>: Character string
Reference format. The specification used for regular expressions is ECMAScript.
Note: You can use the string "(?i)" at the start of an expression to indicate that the check should be case-insensitive.
<Variable 1>: Character string, Integer, etc.
Variable that will be automatically initialized with the value that matches the first part of the <Format>. Each part is defined by the '(' and ')' characters.
<Variable N>: Character string, Integer, etc.
Variable that will be automatically initialized with the value that matches the Nth part of the <Format>. Each part is defined by the '(' and ')' characters.

Checking a format and retrieving the elements that match the format in an array Hide the details

<Result> = <Element to check>.RegexMatch(<Format> , <Array of strings>)
<Result>: Boolean
  • True if the string matches the specified format,
  • False if the string does not match the format.
<Element to check>: Control name
Character string to check.
<Format>: Character string
Reference format. The specification used for regular expressions is ECMAScript.
Note: You can use the string "(?i)" at the start of an expression to indicate that the check should be case-insensitive.
<Array of strings>: Array
Name of the array to be populated. The different elements of the array will be automatically initialized with the values that match the different parts of the <Format>.
Business / UI classification: Neutral code
Component: wd300std.dll
Minimum version required
  • Version 26
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 01/29/2025

Send a report | Local help