ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
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
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 SaaS
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_Résultat is string
// On définit la chaîne à tester et le format qu'elle devrait respecter.
sChaîne is string = "28/03/2003"
sFormatDate is string = "([0-9]+)/([0-9]+)/([0-9]+)"
// Variables pour récupérer les différentes parties du format. 
sJour is string
sMois is string
sAnnée is string
// Si la chaîne vérifie le format alors on affiche ses différentes parties.
IF RegexMatch(sChaîne, sFormatDate, sJour, sMois, sAnnée) THEN
 	TXT_Résultat = "Jours: " + sJour
 	TXT_Résultat += CR + "Mois: " + sMois
 	TXT_Résultat += CR + "Année: " + sAnnée
 END
// Vérification sans tenir compte de la casse
IF RegexMatch(SAI_IMMAT, "(?i)[A-Z]{2}[-][0-9]{3}[-][A-Z]{2}") THEN
...
END
MonEmail is string = "monemail@provider.com"
// Email: vérification de la validité d'un email
IF RegexMatch(MonEmail, "^((?!\.)[\w\-_.]*[^.])(@\w+)(\.\w+(\.\w+)?[^.\W])$") THEN
	Trace("L'email est syntaxiquement correct.")
END
// Mot de passe: vérification de la complexité d'un mot de passe
IF RegexMatch("MotDePasse$1", "^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[^\w\s]).{8,}$") THEN
	Trace("Le mot de passe est fort.")
	// La chaîne contient: 
	// * Au moins 8 caractères, au moins 1 chiffre
	// * Au moins 1 majuscule, au moins 1 minuscule
	// * Au moins 1 caractère spécial
END
// Nombre: vérification permettant de savoir si la chaîne contient un nombre
IF RegexMatch("1.618033", "[-+]?[0-9]*\.?[0-9]*") THEN
	Trace("La chaîne est un nombre entier ou décimal.")
END
// Vérification d'une adresse IP
IF RegexMatch("192.168.100.1", "^(?:(?: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("La chaîne est une adresse IP.")
END
Syntax

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

<Result> = RegexMatch(<Element to check> , <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>: Character string
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> = RegexMatch(<Element to check> , <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>: Character string
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: 07/18/2024

Send a report | Local help