The Regular Expression Generator helps you to
create a regular expression to include in your AQL extractor.
Procedure
Use the Regular
Expression Generator, to select a suggested expression and refine
the expression by examining and modifying the subexpressions that
make up the expression.
Remember: The generated regular
expression adds an escape character to the forward slash character
(//). This adjustment facilitates the use of the forward slash
directly in the AQL file. If you use the regular expression in other
tools, remove the escape character on the forward slash to properly
capture your input examples.
- Regular expression selector
-
The Regular Expression Generator
algorithm suggests one or more regular expressions that match
example strings that you provide.
- Click Load
samples from file.
- After you load your samples, select the
expression that best matches your query, and click Next.
- If you are not satisfied with the results of
this regular expression produces, click Back, and select another expression.
- If you want to modify the samples in the
table, change them, and then click Generate
regular expression to refresh the regular expressions.
- Use the slider to generate more general or
specific regular expressions.
- Regular expression refinement
-
- You can see the regular expression in the Regular Expression text box at the
top of the regular expression refinement page of the wizard. Each
regular expression consists of several subexpressions. For
example,
\d{1,2} or (N|S)
are subexpressions of the following regular expression:
(\d{1,2}(-)( )\d{1,2}(')( )(N|S)(,)( )\d{1,3}(-)( )\d{2}(')( )(E|W))
.
- Refine the individual subexpressions. The
subexpression that you refine is highlighted in the text box.
- Click Next
and Back to navigate to the
next or prior subexpression within your regular expression.
- Samples table
-
- View the Samples
table to see the examples that you entered in the last wizard
page.
The first column (Match)
indicates whether the current regular expression matches the
example of this row.
- The part of the example that is matched by the
current subexpression is highlighted.
- Current® subexpression refinement
-
- The section that is labeled Refine the current subexpression
shows some information about the current subexpression and its
character class. For more information about character classes,
see the Regular
expression constructs and characters. When you refine the
subexpression, you can:
- Make a subexpression optional.
- Change the type of the current
subexpression.
- Make a subexpression optional
-
Select the This subexpression is
optional check box to make a subexpression optional. This action
adds a ? after the
current subexpression, which means {0, 1}. In other words,
the subexpression can occur zero or one time. Use caution when you
make an optional subexpression a mandatory expression. This action
might result in a regular expression that does not match some of
your samples.
- Change the type of the current
subexpression
-
Consider the following constraints when you refine your
subexpression by selecting one of the following options:
-
Any of the symbols in this
character class
-
By selecting this option, any of the symbols that belong to this
character class can occur at this position. Each character class
comprises certain characters. Refer to the table in Regular
expression constructs and characters. You can define the
minimum and maximum number of characters that occur at this
position, which adds {min,
max} after your subexpression, and that means that this
subexpression must occur at least
min
times and can be repeated up to
max
times. Be careful when you increase the minimum number or
decrease the maximum number because this action might result in
a regular expression that does not match some of your samples.
Ensure that all of your examples are still matching after you
modify these numbers.
- One of the samples in the table must
occur
-
The Samples of this
Subexpression table shows all values of this subexpression that
occur in the samples that you provided. If you select this
option, one of the elements in this table must occur at this
position. In other words, the resulting regular expression
contains an alternation of these examples at this position.
- An integer number within a certain
range can occur
-
If the character class is Digit,
you can also select more options to define that an integer
number can occur within a certain range. If you select this
option, click the corresponding radio button and provide a
minimum and maximum integer number for the range. You might also
want to allow leading zeros.
- Test samples
-
You can validate the generated regular expression by manually
entering text into the lower right text area, or you can click Import to load a text file (*.txt) that contains samples. After
some text is entered, the generator highlights the text in the
text area that matches with the regular expression that is
generated.