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
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
MatchRegularExpression (Function)
In french: VérifieExpressionRégulière
Warning
From version 27, this function is kept for backward compatibility. It is recommended to use RegexMatch, which uses the ECMAScript lexical grammar for regular expressions.
Checks whether a character string matches a specific format and retrieves the different substrings that match the format. A wizard in the code editor helps you create the format to be checked.
Example
AndroidAndroid Widget
// Vérification d'une adresse email 
IF MatchRegularExpression(MonEmail, "[-.a-z0-9]+[@][-.a-z0-9]+[.][a-z]{2,4}") = True THEN
	// "[-.a-z0-9]+" : chaîne de 1 ou de plusieurs caractères
	// Cette chaîne peut contenir les lettres 'a' à 'z',
	// les chiffres '0' à '9', et les symboles '-' et '.'
	// [.] indique que ce caractère doit correspondre à un point. 
	// "[a-z]{2,4}" : chaîne contenant 2, 3 ou 4 caractères
	// Cette chaîne peut contenir les lettres 'a' à 'z'
	Info("L'adresse email : " + MonEmail + " est correcte.")
END
Syntax

Checking a format Hide the details

<Result> = MatchRegularExpression(<Element to check> , <Regular expression>)
<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. This string must be written in Latin characters.
<Regular expression>: Character string
Reference format, expressed as a regular expression. This string must be written in Latin characters. This format uses the following characters:
A B C - / _Letters and symbols to check.
[A-Z] or [0-9]Interval of letters, digits or symbols to check.
*0 or more symbols to check.
+1 or more symbols to check.
\WChecks for special characters (e.g., &, #, @, etc.).

Note: Use the | (pipe) character to define an "OR" condition.

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

<Result> = MatchRegularExpression(<Element to check> , <Regular expression> , <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. This string must be written in Latin characters.
<Regular expression>: Character string
Reference format expressed as a regular expression. This string must be written in Latin characters. This format uses the following characters:
A B C - / _Letters and symbols to check.
[A-Z] or [0-9]Interval of letters, digits or symbols to check.
*0 or more symbols to check.
+1 or more symbols to check.
\WChecks for special characters (e.g., &, #, @, etc.).

Note: Use the | (pipe) character to define an "OR" condition.
<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.
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst

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

<Result> = MatchRegularExpression(<Element to check> , <Regular expression> , <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. This string must be written in Latin characters.
<Regular expression>: Character string
Reference format. This string must be written in Latin characters. This format uses the following characters:
A B C - / _Letters and symbols to check.
[A-Z] or [0-9]Interval of letters, digits or symbols to check.
*0 or more symbols to check.
+1 or more symbols to check.
\WChecks for special characters (e.g., &, #, @, etc.).

Note: Use the | (pipe) character to define an "OR" condition.
<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>.
Remarks
Related Examples:
The regular expressions Unit examples (WINDEV): The regular expressions
[ + ] Using regular expressions with WINDEV.
Two use modes are presented for the regular expressions:
- checking the input format
- checking out different elements while respecting the input format.
This example is also used to search for a word in a string. The search can be case-sensitive or not. Possibility to take into account (or not) the start or end of string, as well as spaces (anywhere in the string, even in the sought word)
The regular expressions Unit examples (WINDEV Mobile): The regular expressions
[ + ] Using regular expressions with WINDEV Mobile.
It presents 2 modes for using the regular expressions:
- check the input format
- check out the different elements that match the input format.
This example is also used to search for a word in a string. The search can be case-sensitive or not. Possibility to take into account (or not) the start or end of string, as well as spaces (anywhere in the string, even in the sought word)
Advanced input mask Unit examples (WINDEV): Advanced input mask
[ + ] Handling the input masks in WINDEV:
- Defining the format of positive/negative number in a numeric edit control
- Defining how negative numbers will be displayed in a numeric edit control
- Defining how the value 0 will be displayed in a numeric edit control
- Using a regular expression to prevent from typing characters other than 1, 2, 3, 4, 5 and 6.
- Using a regular expression to "regulate" the input of a French registration number
Component: wd300std.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help