|
Create a Simple ezParse Rule |
Let’s create a rule called DoubleQuotedText for a file with the extension TXT. This will identify text between double-quotes. It is a very versatile rule that can be adapted to many situations.
Select File Types & Parsing Rules from the HOME ribbon.
From the File Groups list control, select Text Based Files. Select TXT from the File Extension list, then select Add from the Rules section of this dialog panel . Type DoubleQuotedText when requested to do so and then press OK.
Now that you’ve created a Rule called Double Quoted Text, double-click it, or highlight the rule and select Edit Rule.
In the resulting dialog, enter a double quote as the StartTag and the EndTag
While editing the Start and End tags, right click the field to access the context menu which includes an optional list of common regular expression with their explanation.
In the Preview section, use the browse button and locate the file idbasedfiles.txt. Press the Preview button to display the contents of the file in the File Preview window. The left hand window displays the raw file with colour coding to indicate the start tag, localizable text and end tag. The right hand window displays the extracted text based on the rule we have just created.
|
The preview of the original file is colour coded to help debug ezParse rules. A different colour is used for each element in a matching rule so you can easily spot when rules mismatch content in your file. Salmon colour indicates the Start Tag Yellow is the EndTag |
|
For more information on developing Regular Expressions, please refer to Working with Regular Expressions. |
This file has translatable text enclosed between double-quote characters. In addition to this it has an ID at the start of each line that uniquely identifies each string. For this simple rule, we did not attempt to extract the ID. To understand how to extract the text and the ID, see the topic Create an Advanced ezParse Rule.
The ezParse rule is now complete and can be used to extract text from any file with a similar format. Press OK to close the Edit Methods dialog and OK again to save the rule on your machine.