# Regex Model Syntax

The regex model A specific spatial arrangement of a set of features (Blue Locate and Blue Read tools only.) During a post-processing step, the Blue Locate and Blue Read tools can fit all of the features detected in an image to the models defined for the tool. The overall pose and identity of the model is then returned. uses the following syntax:

Code | Definition
--- | ---
. | Matches any character, except for space.
[A-Za-z] | Matches any English character. See "Character classes" below.
[^A-Z] | Matches any character, except for space and the upper case characters.
\d, \u | Equivalent to [0-9] and [A-Z] respectively.
jan|feb | Matches either "jan" or "feb"
() | Groups characters. Useful if followed by ?, *, +, or {5}, or to delimit the range of or an either/or expression using |.
space | Space is special. It does not match any feature A feature is a visually distinguishable area in an image. Features typically represent something of interest for the application (a defect, an object, a particular component of an object)., but tells the Blue Read tool's model matcher to expect a longer gap between features here, which affects the scoring.
\*, \?, \+, \(, \), \[, \], \{, \}, \., \|, \\ | Escapes a literal control character.
? | The preceding expression is optional.
* | The preceding expression repeats 0 or more times.
+ | The preceding expression repeats 1 or more times.
{5} | The preceding expression repeats exactly 5 times.
{5,8} | The preceding expression repeats 5 to 8 times, inclusive.
Other character | Matches that character literally.

Inside of character classes (for example [a-z]) the following syntax rules apply:

- A - denotes a range, unless it occurs at the beginning of the class specification (possibly after ^) or at the end. If you need a literal -, place it in one of those locations.
- A closing square bracket ] ends the class, unless it is escaped with \, or it occurs at the very beginning of the class specification (possibly after ^).

- If you want a backslash, you should escape it with another backslash.

  Note: The only characters with special meaning are ], -, and \. Any other character (for example *, ?, ), |, etc) have their literal meanings, and should not be escaped.

### Space in a Regex String

You use space (blank) characters in the regex string to indicate expected gaps between characters. If you specify a large gap the tool may skip over characters during matching. A general guideline is to use a space character to indicate a gap that is as large as the feature size The subjective size of the image features that you feel are most important for analyzing image content. The feature size determines the size of the image region used for sampling. Only used with Blue Locate, Blue Read, and Legacy type tools. you've specified.

As described in the Regex Model Syntax topic, a (normal ASCII) space character is special. It does not match a feature, but tells the model matcher to expect a bigger gap between features at that position. You can add several spaces if wider gaps are expected. The final "match string" for the model will include those spaces.

Space is the only character that is special. Other whitespace characters simply try to match a feature which is labeled with that particular character.

Note: The regex model does not support any "multi-line" models. CR or LF characters have no special meaning.

### Unicode Character Matching for Regex Model

The regex model supports matching Unicode characters, with the caveat that it operates in units of Unicode code points – each feature is assumed to correspond to a Unicode code point.

Note: In Unicode, there are so-called "combining characters", which means that a character can consist of several code points. This is a common way to express unusual combinations of diacritics.

Unicode provides so-called precomposed characters – characters (even with diacritics) which only consist of a single code point. To ensure that these are used, the user should use the Unicode normalization form NFC. (Notable exceptions are half-width Japanese kana with dakuten or handakuten diacritics – these have no precomposed form in Unicode.)

### Regex Models and Empty Features

When labeling Labeling is the process of annotating an image with "ground truth". Depending on the tool that you are using, labeling can take different forms. You label an image set for two reasons: to provide the information needed to train the tool and to allow you to measure and validate the performance of the trained tool against the ground truth. characters for training Training is the process that your tool, which is a neural network, is learning about the features (pixels) based on the labels you made. For example, a tool will learn the defect/normal pixels in each image based on the defect/normal labels you drew. The goal of the tool Training is learning enough to give the correct inspection results of whether an unseen image is defective or not. The key to training is to ensure that you include all possible variations within your training set, and that your images are accurately labeled. Training times vary by the application, tool setup and the GPU in the PC being used to train the network., after a labeled feature has been added, but before it has been given a character, it exists in a special "empty" state. As a special case, the regex model will always be able to match empty features, regardless of the character class or literal character used. This helps with work flows where you are using the model to be able to enter the ground truth Ground truth refers to the actual nature of the problem that is the target of a machine learning model, reflected by the relevant data sets associated with the use case in question. Supervised machine learning models are trained on labeled data that are considered for the model to identify patterns that predict those labels on new data. for many features as one string.