[TxMt] a regexp test script (link)
Robert Ullrey
robert_ullrey at mac.com
Sun Apr 3 15:57:03 UTC 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
David,
Looks great....Now the stupid question. How do I use it?
Should I place this in TextMate as a snippet and then type in a line of
regexp to test and run the rx_helper over it, or install this a as a
command within the ruby bundle. Alternately, should I have my file open
in textmate and then write my rexexp in the "filter through command"
after calling rx_helper.
Thanks for the work, and the time to explain its use
Robert
On Apr 3, 2005, at 6:37 AM, David Lee wrote:
> Hi all
>
> I've written a short ruby script for the purposes of checking regular
> expressions within TextMate.
>
> http://dml.homedns.org/rx_helper.rb
>
> It expects to be fed a regular expression on a line of its own,
> followed by any number of lines to test against. The RX can be either
> a straight match (eg ^([a-z]+):([0-9]+ ) or a substitution (eg,
> /old/new/). Cuddling /slashes/ are only required for
> /pattern/replacement/ expressions.
>
> If you create the following action in TextMate:
>
> echo "$TM_SELECTED_TEXT" | /path_to_script/rx_helper.rb
>
> with input='selected text' & output='show as tooltip', you can open a
> new window, write a regexp, write some test cases for your regexp,
> then select-all and see the results in a tooltip whenever you need it
> (I have it bound to ctrl-alt-option-X).
>
> I hope someone finds it useful. If you find any bugs / have any
> suggestions on how to improve it, please do let me know.
>
> cheers
>
> D
>
> P.S here's some sample input and output:
> ------------------------------------
> IN (TextMate scratch file)
> ==
> (http|https|ftp):\/\/(([-_a-zA-Z1-9]+)\.)+([-_a-zA-Z1-9]{2,3})
> 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
> ~
>
> OUT (tooltip)
> ==
> (http|https|ftp):\/\/(([-_a-zA-Z1-9]+)\.)+([-_a-zA-Z1-9]{2,3})
> Successful Matches:
> ===================
> http://www.google.com : matched expression
> match number [1] : http
> match number [2] : google.
> match number [3] : google
> match number [4] : com
> https://www.netbank.com.au : matched expression
> match number [1] : https
> match number [2] : com.
> match number [3] : com
> match number [4] : au
> ftp://mafia.ru : matched expression
> match number [1] : ftp
> match number [2] : mafia.
> match number [3] : mafia
> match number [4] : ru
> http://www.amazon.com/ : matched expression
> match number [1] : http
> match number [2] : amazon.
> match number [3] : amazon
> match number [4] : com
> http://www.amazon.com/exec/obidos/subst/home/home.html/002-0270779
> -6984007 : matched expression
> match number [1] : http
> match number [2] : amazon.
> match number [3] : amazon
> match number [4] : com
>
> Failed Matches:
> ===============
> www.clickstart.com : failed
> boozehound : failed
> gary sweeney : failed
>
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate
>
-----BEGIN PGP SIGNATURE-----
Version: PGP 8.1
iQA/AwUBQlASWmO1AQX/YDblEQK6HwCeOI17A5+LGZfOy8MaQXQMKPGaLCIAn0mn
We4Jdx/9UCM9/r7cxGghP7wH
=L5Pz
-----END PGP SIGNATURE-----
More information about the textmate
mailing list