[TxMt] a regexp test script (link)
Eric Hsu
erichsu at math.sfsu.edu
Mon Apr 4 21:31:45 UTC 2005
I've written an alternative version of the regular expression
checker. It relies heavily on a script I found on the web by
Aristotle at perlmonks.org (cited in the code).
I've checked it into the svn repository. There's also a version of
the Ruby script that produces a tooltip (though I can't get that to
work on my computer yet). They live at
http://macromates.com/svn/Bundles/trunk/RegularExpressions.tmbundle/
The way this alternative works is you copy the regexp to the
clipboard, then highlight the text you want to check. Then it
produces HTML output which color codes each subcapture.
There might be a nicer way to grab the regexp, like maybe using
Cocoadialog, but I just wanted to get this out there.
best wishes, Eric
ps. Here's what you get with the sample file David Lee posted:
CLIPBOARD
(http|https|ftp):\/\/(([-_a-zA-Z1-9]+)\.)+([-_a-zA-Z1-9]{2,3})
INPUT
http://www.google.com
https://www.netbank.com.au
ftp://mafia.ru
www.clickstart.com
boozehound
gary sweeney
http://www.amazon.com/
http://www.amazon.com/exec/obidos/subst/home/home.html/002-0270779-6984007
OUTPUT.
<html><head></head><body>
<h3>Results for
/(http|https|ftp):\/\/(([-_a-zA-Z1-9]+)\.)+([-_a-zA-Z1-9]{2,3})/</h3><tt>
<b><font color="Red"></font></b><b><font color="Dark
Blue">http</font></b><b><font color="Red">://www.</font></b><b><font
color="Dark Purple">google.</font></b><b><font
color="Red"></font></b><b><font
color="Brown">google</font></b><b><font
color="Red">.</font></b><b><font
color="Burgundy">com</font></b><b><font color="Red"></font></b>
<br/><b><font color="Red"></font></b><b><font color="Dark
Blue">https</font></b><b><font
color="Red">://www.netbank.</font></b><b><font color="Dark
Purple">com.</font></b><b><font color="Red"></font></b><b><font
color="Brown">com</font></b><b><font color="Red">.</font></b><b><font
color="Burgundy">au</font></b><b><font color="Red"></font></b>
<br/><b><font color="Red"></font></b><b><font color="Dark
Blue">ftp</font></b><b><font color="Red">://</font></b><b><font
color="Dark Purple">mafia.</font></b><b><font
color="Red"></font></b><b><font
color="Brown">mafia</font></b><b><font
color="Red">.</font></b><b><font
color="Burgundy">ru</font></b><b><font color="Red"></font></b>
<br/>www.clickstart.com
<br/>boozehound
<br/>gary sweeney
<br/><b><font color="Red"></font></b><b><font color="Dark
Blue">http</font></b><b><font color="Red">://www.</font></b><b><font
color="Dark Purple">amazon.</font></b><b><font
color="Red"></font></b><b><font
color="Brown">amazon</font></b><b><font
color="Red">.</font></b><b><font
color="Burgundy">com</font></b><b><font color="Red"></font></b>/
<br/><b><font color="Red"></font></b><b><font color="Dark
Blue">http</font></b><b><font color="Red">://www.</font></b><b><font
color="Dark Purple">amazon.</font></b><b><font
color="Red">com/exec/obidos/subst/home/home.html/002-0270779-6</font></b><b><font
color="Brown">amazon</font></b><b><font
color="Red">.</font></b><b><font
color="Burgundy">com</font></b><b><font
color="Red"></font></b>/exec/obidos/subst/home/home.html/002-0270779-6984007
<br/></tt></body></html>
--
Eric Hsu, Assistant Professor of Mathematics
San Francisco State University
erichsu at math.sfsu.edu
http://math.sfsu.edu/hsu
More information about the textmate
mailing list