|
Advanced ezParse Rules |
|
ezParse can use regular expressions to create complex and advanced rules. For example, it's possible to write a rule that extracts not only the text from a file but also a unique ID. This unique ID ensures a more accurate re-use of these text during Leverage and Validate operations and is a very powerful way of localising text based files.
|
In this example, we're going to use the IdBasedfile.txt and enhance the ezParse rule MyNewParser that we previously created. |
Go to the General Options dialog box. (Click on Tools - Options or on the button on the main project Your project is where you manage and organize all the files that are to be localised. toolbar.)
Select ezParse from the list of options displayed on the screen.
Click on Text Based Files. Then select the file extension TXT from the File Extension list.
Click on the ruleMyNewParser and then select Edit Methods to modify and update this rule.
In the Methods enter the following rule information in the Start Tag column: (^[^=]+)= ".
Click on the Browse button in the Preview Panel and specify the file IdBasedfile.txt as the file you'd like to run this run on. You will locate this sample file in the \samples folder on your product CD. Then click on the Preview button to see the results of the rule on this file.
Notice that the text IDs are now appearing in the ID column in the Preview window. The enhanced regular expression we've just used not only identifies the text in our test file but also the IDs. The regular expression An expression that can be created using wildcard operators (such as ? * [] ). we used is a good example of how advanced we can be in parsing files. The regular expression can be broken down and analyzed as follows:-
Regular Expression Token |
Description |
^([^=]+) = |
This hat symbol denotes the token Start of Line. |
(..........) |
The braces indicate that the contents of the enclosed regular expression is an ID field and should be extracted and stored in the ID column of a project ttk file. |
[^=]+ |
The square braces indicate that a group is being defined. In this example the group is not an equal sign. The + is a repeater and denotes at least one of more times. |
Now that we've completed our ezParse rule, press OK to return to Alchemy CATALYST.
© Copyright Alchemy Software Development 2009 |
|