Using Rx ToolkitKomodo includes Rx Toolkit, a tool to help you build, edit, and debug your regular expressions. This section describes how to use Rx Toolkit to work with your regular expressions. Note - This release only supports Perl regular expressions. If you are new to Regular Expressions, see Regular Expressions Primer. Starting Rx ToolkitTo start Rx Toolkit, do one of the following:
![]() Getting Acquainted with Rx Toolkit WindowTake a Visual Tour of the Rx Toolkit
Creating Regular ExpressionsUse the features of Rx Toolkit to create and edit your regular expressions. This section describes:
Entering Your Regular Expression
To enter your regular expression:
Your regular expression can include metacharacters, anchors, quantifiers, digits, and alphanumeric characters. Note - Do not enclose your regular expression in forward slashes "/". Rx Toolkit does not use enclosing slashes. ![]() Viewing Node Highlighting
Rx Toolkit features node highlighting to help you create your regular expressions. When you hover over a node in your regular expression, Rx Toolkit highlights the node in green.
If you hover over the modifier or metacharacter for a node, the symbol is highlighted in green and the part that it modifies is highlighted in grey.
If you hover over the parentheses or braces that indicate a group match, Rx Toolkit highlights the parentheses or braces in green and highlights their contents in grey. Rx Toolkit also highlights the group match in the test string.
![]() Viewing Node Tips
Rx Toolkit features node tips to help you create your regular expressions. Rx Toolkit also provides node tips in the Rx Toolkit status bar below the Regular Expression box to help you design an effective regular expression. You can view these node tips as you hover over your regular expression. For example, if the regular expression is (.*)(\d+) and you hover over each character in order from left to right:
![]() Adding Valid Metacharacters to Your Regular Expression
The Shortcuts menu provides a list of all the metacharacters and metasymbols that are valid at the current cursor position in your regular expression. This menu lists the metacharacter and a brief description of the metacharacter. When you move the cursor position, this list changes to reflect only the valid metacharacters for that current cursor position. To add a valid metacharacter to your regular expression:
or
![]() Adding Modifiers to Your Regular Expression
To add a modifier to your regular expression:
Note - Ensure you use the Modifiers checkboxes to add modifiers to your regular expression. Rx Toolkit does not understand modifiers entered in the Regular Expression box. ![]() Viewing Sample Regular ExpressionsThis section shows some sample regular expressions with different modifiers applied, including:
Using GlobalThe Global modifier matches all occurrences of the specified regular expression. Use this when you want Rx Toolkit to cycle through several repetitions in your test string. To match the following test string
you could use the following regular expression with Global selected
Click Advanced to view your Group Match Variables output, which would look like this
DiscussionThis regular expression matches the entire test string. The .* matches any character zero or more times, the ? tells * to not be greedy, which means (.*?) matches the words "testing" and "foobar". The (\d+) matches any digits one or more times, which matches the numbers "123" and "75". The Global modifier means that Rx Toolkit matches more than the first occurrence of the pattern. That's why Rx Toolkit matched $1 and $2 twice. ![]() Using Multi-line ModeThe Multi-line Mode modifier allows ^ and $ to match next to newline characters. Use this when your pattern is more than one line long and has at least one newline character. To match the subject part of the following test string
you could use the following regular expression with Multi-line Mode selected
Click Advanced to view your Group Match Variables output, which would look like this
DiscussionThis regular expression matches the entire test string. The ^ matches the beginning of any line. The \" matches the double quotes in the test string """. The match matches the literal word "okay". The \? matches the question mark "?". The \" matches the terminal double quotes """. There is only one variable group in this regular expression, and it contains the entire test string. ![]() Using Ignore CaseThe Ignore Case modifier ignores alphabetic case distinctions while matching. Use this when you don't want to specify the case in the pattern you're trying to match. To match the following test string
you could use the following regular expression with Ignore Case selected
Click Advanced to view your Group Match Variables output, which would look like this
DiscussionThis regular expression matches the entire test string. The ^ matches the beginning of a string. The [a-z] matches any lowercase letter from "a" to "z". The + matches any lowercase letter from "a" to "z" one or more times. The Ignore Case modifier allows the regular expression to match any uppercase or lowercase letters. Therefore ^([a-z]+) matches "Testing". The (\d+) matches any digit one or more times, so it matches "123". ![]() Using Single-line ModeThe Single-line modifier mode allows . to match newline characters. Use this when your pattern is more than one line long, has at least one newline character, and you want to match newline characters. To match the following test string
you could use the following regular expression with Single-line Mode selected
Click Advanced to view your Group Match Variables output, which would look like this
DiscussionThis regular expression matches everything in the test string following the word Subject, including the colon and the question mark. The (\s+) matches any space one or more times, so it matches the space after the colon. The (.*) matches any character zero or more times, and the single-line modifier allows the period to match the newline character. Therefore (.*) matches "Why did this <newline> match". The \? matches the terminal question mark "?". ![]() Using ExtendedThe Extended modifier ignores whitespace and comments in the regular expression. Use this when you want to pretty print your regular expression or when you want to annotate your regular expression with comments. To match the following test string
you could use the following regular expression with Single-line Mode selected
Click Advanced to view your Group Match Variables output, which would look like this
DiscussionThis regular expression matches the entire test string. The .* matches any character zero or more times, the ? makes the * not greedy, and the extended modifier ignores the spaces after the (.*?). Therefore, (.*?) matches "testing" and populates the variable $1. The (\d+) matches any digit one or more times, so this matches "123" and populates the variable $2. The extended modifier ignores the spaces after (\d+) and ignores the comments at the end of the regular expression. ![]() Using Multi-line Mode and Single-line ModeTo match more of the following test string
you would need both Multi-line Mode and Single-line Mode selected for this regular expression
Click Advanced to view your Group Match Variables output, which would look like this
DiscussionThis regular expression matches everything in the test string following the word Subject, including the colon and the question mark. The ([\t ]+) matches a Tab character or a space one or more times, which matches the space after the colon. The (.*) matches any character zero or more times, which matches "Why did this <newline>". The ^match matches the literal "work" on the second line. The \? matches the terminal question mark "?". If you used only the Single-line Mode modifier, this match would fail because the caret "^" would only match the beginning of a string. If you used only the Multi-line Mode modifier, this match would fail because the period "." would not match the newline character. ![]() Using Multi-line Mode, Ignore Case and GlobalIf you want to match the contents of a standard email header, you would compose your regular expression and apply three modifiers: multi-line, ignore case, and global. To match more of the following test string
you could use for this regular expression with Multi-line Mode, Ignore Case, and Global selected
Click Advanced to view your Group Match Variables output, which would look like this
DiscussionThis regular expression matches each part of the email header. The ^ matches the beginning of any line. The ([a-z]+) matches any lowercase letter one or more times. The : matches a colon and the \s+ matches a space one or more times. The (.+?) matches any character one or more times. The $ matches the end of a line. Multi-line Mode allows caret "^" to match the beginning of any line. Without the multi-line mode modifier, caret "^" matches the beginning of a string. Ignore Case allows Rx Toolkit to match any lower or uppercase letter. Without the ignore case modifier, there would be no group match variables. Global allows Rx Toolkit to keep matching after the first match is found. Without global, Rx Toolkit only matches the first line, "From: joe@domain.com". ![]() Evaluating Regular ExpressionsA debugged regular expression correctly matches the patterns you intend and provides information about which variable contains which pattern. If there's a match... If your regular expression matches the test string:
If there's no match... If your regular expression does not match the test string:
![]() Evaluating Your Regular Expression on a Node by Node Basis
|
![]() |