Custom Entity Types

Extract a Zip Code

Sometimes you'll want to create your own entity type when the built-in options do not fit with the user reply you are expecting.

In this video example, we will be creating an entity type that is specifically for zip codes.

The RegEx Library

You can find a number of other regular expressions to create your own entity types at https://uibakery.io/regex-library

Here is the code used in the Code Step

errorMessage = 0;

// Extract zip code from a string
var zipRegexG = /[0-9]{5}(?:-[0-9]{4})?/g;

try {
    zipcode = zipcode.match(zipRegexG)[0];
}
  catch(e) {
    errorMessage = "Looks like it's not a zipcode" // or e.message;
}