Generating regular expressions

The Regular Expression Generator helps you create a regular expression to include in your AQL extractor. Before you begin, create a list of examples that depict the concept behind the regular expression that you want to generate. Collect examples into a simple text file (*.txt), one per line. Each example must be terminated by a newline character. If you do not have a list of examples, alternatively you can enter them manually into the Samples table.

About this task

A regular expression , also referred to as regex or regexp, provides a concise and flexible means for matching strings of text, such as particular characters, or words. A regular expression is written in a formal language that can be interpreted by a regular expression processor , a program that examines text and returns matches to provided specifications.

Procedure

  1. Generate a new regular expression:
    1. Click Regular Expression Generator on the InfoSphere® BigInsights™ Eclipse toolbar.
    2. In the Regular Expression Generator wizard, click Load samples from file to select your list of examples, select a regular expression to refine, and click Next.
    3. Refine the expression, and click Finish. For details about refining the expression, see Regular Expression Generator. The regular expression is copied to the clipboard.
    4. Place your cursor within an AQL statement where a regular expression would appear, right-click, and select Paste.
  2. Generate a regular expression to replace an existing expression. If you do not want to replace an expression, create an empty expression marker by using two slash (/) characters in an existing, syntactically correct AQL statement, for example:
    					create view MyRegex as
    extract regex // as match
    from Document D;
    
    
    create view MyRegexes as
    extract regexes /\d+/ and // as match
    from Document D;
    
    
    create view MyRegexFilter as
    select * 
    from Phone P
    where MatchesRegex(//, P.number);
    				
    1. Right-click a syntactically correct regular expression between the two slash (/) characters that surround the regular expression, and select Regular Expression Generator from the pop-up menu. If Regular Expression Generator is not available from the pop-up menu, your cursor is not positioned between the two slash (/) characters that surround a syntactically correct regular expression.
    2. In the Regular Expression Generator wizard, click Load samples from file to select your list of samples, select a regular expression to refine, and click Next.
    3. Refine the expression, and click Finish. For details about refining the expression, see Regular Expression Generator.

Results

The regular expression replaces the original regular expression in the file.