Skip to main content
Mitratech Success Center

Custom Field Type for Postcodes

This example uses a regular expression (also known as regex) to match strings of text in a file. In this example, you will create a simple regular expression to match a postcode in a text file.
Regular expressions are used in computing and various ‘variants’ have been created. DataStore®DSX uses single-line mode regular expressions. See “Positions Ribbon Buttons” and Regular Expressions” for more information on the supported characters.

  1. In the tree view, select Custom Field Type, right-click and select New. The Custom Field Type Editor is displayed.
  2. Enter a Name for the Custom Field Postcodes in this example.
  3. Set the Field type. In this example, Text. If required, select Override default and add Help text or ToolTip text.
  4. This Custom Field must have the format SL1 6BB or SL12 6BB i.e., LETTER LETTER NUMBER space NUMBER LETTER LETTER. These formats will be checked using a regular expression. Select the Validation tab then select Override default validation properties and select Regular Expression mask. Click the Regular Expression Generator button to open the Regular Expression Generator window.
    image
     
  5. Enter a valid postcode in the Selected text box and generate a Regular Expression by clicking the generate button (as shown below).image
     
  6. The suggested regular expressions are for the postcode SL1 6BB, but the postcode SL12 6BB is also valid and so the regular expression must be edited so it matches both postcodes. Click the exact match regular expression to display it in the Regular Expression box. Then edit the suggested regular expression to allow 1 or 2 digits after the initial two letters (shown in blue):
    ^[a-zA-Z]{2}\d{1,2}\s\d{1}[a-zA-Z]{2}$
     
  7. If required, add the postcode regular expression to the Private or Public library and then close the window.image
     
  8. Click Save to save the regular expression mask and exit the Custom Field Type Editor.

Note: The regular expression created for the postcode is not as complex as it needs to be to cater for all UK postcodes.

This Custom Field Type can now be used in one or more Data Definitions.

  • Was this article helpful?