|
|
|
|
|
- Wizard of the RegexMatch function
RegexMatch (Function) In french: RegexVérifie 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 2025TXT_Result is string
sString is string = "28/03/2003"
sDateFormat is string = "([0-9]+)/([0-9]+)/([0-9]+)"
sDay is string
sMonth is string
sYear is string
IF RegexMatch(sString, sDateFormat, sDay, sMonth, sYear) THEN
TXT_Result = "Days: " + sDay
TXT_Result += CR + "Month: " + sMonth
TXT_Result += CR + "Year: " + sYear
END
IF RegexMatch(EDT_LICENSEPLATE, "(?i)[A-Z]{2}[-][0-9]{3}[-][A-Z]{2}") THEN
...
END
MyEmail is TO string = "monemail@provider.com"
IF RegexMatch(MyMail, "(?i)[^\.][a-zA-Z0-9._%&#{}+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z.-]{2,}$") THEN
Trace("The email is syntactically correct.")
END
IF RegexMatch("Password$1", "^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[^\w\s]).{8,}$") THEN
Trace("The password is strong.")
END
IF RegexMatch("1.618033", "[-+]?[0-9]*\.?[0-9]*") THEN
Trace("The string is an integer or decimal.")
END
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("The string is an IP address.")
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>. Remarks New in SaaSWizard of the RegexMatch function RegexMatch allows you to use a function wizard in the code editor. This wizard allows you to: - use a preset regular expression. A list of preset regular expressions is available.
- view the regular expression as a diagram or as a sequence of conditions in a table.
- create a regular expression. Simply:
- Select the "Custom" preset expression.
- Click
. - Add the different conditions via the "+" button. The regular expression is built in the "Generated regular expression" field.
- Enter the expression to be checked.
- The
button allows you to save the regular expression. It will appear in the list of preset regular expressions, preceded by "Custom".
Related Examples:
|
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)
|
|
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)
|
|
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
|
Business / UI classification: Neutral code
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|