|
See Also Regular Expression Syntax Using Regular Expressions |
|
If you are not familiar with regular expressions and want to learn how to use them, or want to test your own expressions, the Regular Expression Laboratory will help you much. Its main intent is to visualise both the internals of the expression compilation process and how the prepared expression matches the text portions.
At the heart of the regular expression engine is a concept of a finite-state automata. You can treat this automata as a tiny virtual computer working by a program. The program that the automata runs is the precompiled binary form of an expression. In other words, the textual expression that you provide is first compiled into a binary form and then executed against a text.
This is why you get regular expression errors sometimes. Some applications may even crash if the regular expression faults are not handled properly. Using the Regular Expression Laboratory, you will easily get a robust working expression.
You can open the Laboratory by clicking button
in the Files and Text main window tab or Scenario
Editor.
The following picture illustrates the Regular Expression Laboratory front-end.
Using it is fairly simple. What is more, the Laboratory provides you with visual cues when you are mistaken with your expression. The below given sequence is usually the best practice.
\<[^\>]#\> \L\0The tables below describe the dialog fields.
| Field | Description |
|---|---|
| Search pattern text box | Contains the search expression. |
Search pattern button |
Shows a menu with regular expressions that you can select and insert. |
Multiline editor button |
Click this button to open the Multiline Editor dialog. This dialog allows entering text with multiple lines in normal mode, converting line breaks to \r and \n
as appropriate. |
| Match button | Compiles the provided expression and tries to match it against the sample text. Click this button again to find the next match in the sample text. You can press and hold this button to iterate through the text. |
| Sample text box | Contains the sample text that the expression will match against. |
Sample text button |
Allows to load the sample text from file. |
| Highlight stored expressions | If checked, the matching stored expressions, i.e. those enclosed in parentheses ( ) will have different background colour in the sample text box. |
| Replace pattern text box | Contains the replacement expression. |
Replace pattern button |
Shows a menu with regular expressions that you can select and insert. |
Multiline editor button |
Same purpose as for the Multiline editor button for the Search pattern. |
| Apply button | Given the replacement expression, performs the replace operation on the sample text. |