Made with Xojo: RegExRX
Issue: 11.4 (July/August 2013)
Author: Marc Zeedar
Article Description: No description available.
Article Length (in bytes): 5,114
Starting Page Number: 16
Article Number: 11403
Related Web Link(s):
Full text of article...
If you've ever needed to create a regular expression pattern—a "regex"—you know how time-consuming they can be to write and debug. But Xojo developer Kem Tekinay is here to the rescue with his RegExRX application.
The program has a simple three-pane structure, showing your search pattern, the source text (with found items highlighted), and a "match list" listbox which lets you see each subexpression the pattern matched. (Clicking on a match list item highlights it in the source text.)
If you choose the "Replace" tab at the top of the window (versus the default "Search"), two new fields are added to the interface: a replace pattern and a TextArea showing the text after the regex has been run.
All of the fields are resizable; you can drag a widget between them to adjust the size of each field.
In the regex pattern fields, your pattern's syntax is colored to make the various elements easier to identify.
There are also handy "insert" menus which let you quickly insert common regex terms. For instance, there's a "wildcards" category which includes items such as "." (which is any character) and ".+" (any character one or more times). Each menu item is followed by a brief description to remind you what the regex command does.
The categories are well-defined, such as "character classes," "special characters," "repetition," "groupings," "conditionals," "modes," "subroutines," and much more. This makes it fairly easy to find what commands you're seeking.
The "replace" insert menu has different options than the search pattern field.
"(?xmi-Us) # FREE SPACING MODE—whitespace ignored" + EndOfLine + _
"(?:[^[:punct:]\s[:cntrl:]'‘’]+[’'][^[:punct:]\s[:cntrl:]'‘’]+)" + EndOfLine + _
" # A run of characters that are not a punctuation," + EndOfLine + _
" # whitespace, or control character, followed by a" + EndOfLine + _
" # single quote, then another run of characters that" + EndOfLine + _
" # are not a punctuation, whitespace, or control character" + EndOfLine + _
"| # OR" + EndOfLine + _
"[^[:punct:]\s[:cntrl:]'‘’]+" + EndOfLine + _
" # Just a run of characters that are not a punctuation," + EndOfLine + _
" # whitespace, or control character"
You can also paste a pattern into RegExRX from those same sources (such as Xojo), which reverses the process.
Because each regex you create in RegExRX is its own document, you can save the entire window (patterns, source text, etc.) as a file and restore it at will. This is really handy, as you may not fully debug a regex at one sitting and being able to come back to it later is awesome.
RegExRX is powerful and useful; I know I'll be using it for all my future regex needs. My only complaint is the lack of regex documentation. Granted, there are entire books on regex (and if you're doing complex regex you should definitely invest in one), but it would still be nice if there was some built-in documentation to remind you of the basics. There are sample regex patterns you can download which are educational, and the descriptions on the insert menus are helpful, however. RegExRX is definitely a tool all Xojo developers should have in their toolbox.
End of article.