RTL.RegExpressionFMX Sample
Contents
RegExpressionDemo is a sample that demonstrates how to use regular expressions in an application.
Location
You can find the RegExpressionDemo sample project at:
- Start > Programs > Embarcadero RAD Studio > Samples > Delphi > RTL > RegExpression > fmx
- Subversion Repository for Delphi: http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RADStudio_Seattle/Object%20Pascal/RTL/RegExpression/fmx/
Description
This application allows the user to test the validity of a string with regard to a regular expression.
The form contains a list box, a memo, and an edit box. From the list box the user can choose to validate an e-mail address, an IP address, or a date in either of two formats. When one of the options is selected from the TListBox, the regular expression that is used for validation is displayed in the TMemo component. Next, the user can enter a string in the TEdit to see whether the input is valid according to the regular expression.
How to Use the Sample
- Navigate to the location given above and open RegExpressionDemo.dproj.
- Press F9 or choose Run > Run.
Files
This project has one source file, Main, which contains the class for the main form.
Classes
TForm1, the class for the main form, handles the display of visual components and the validation of strings by using regular expressions.
Implementation
- When an item is selected from the list box, the corresponding regular expression is added to the TMemo.
- The input string is evaluated with the TRegEx.IsMatch method.
- A TShadowEffect activates on the main form in order to show in green or red whether the input corresponds with a regular expression or not.