This post is basically a review of an emacs-module but since Reviews only covers CPAN and books I'll add it here in meditations, it's a repost from emacs-perl-intersection group!

Hi guys

I gave regex-tool.el a try, it's an interactive regex tester like regex-builder, but can be modfied customized to work with perl.

http://github.com/jwiegley/regex-tool/blob/master/regex-tool.el

The project hasn't been updated for 2 years now, but I like it!

It's a very small but functional module (190 lines incl. docs) which can be easily modified, especially the embedded perlcode!

Furthermore I found a workaround to test just more than a line by just adding a (?x) in the first line.

This makes it an extended regex and you can experiment by simply commenting lines out:

(?x) #multiline #(?i) # do I want it case sensitive? prematch(group) # your regex

Komodo's RegEx tester may look more comfortable, but it runs on Python's PCRE engine not Perl, which may cause special problems!

http://docs.activestate.com/komodo/5.1/tutorial/tourlet_rx.html

Here some nice DHTML tester I found

  • http://osteele.com/tools/rework/
  • http://erik.eae.net/playground/regexp/regexp.html

    Cheers Rolf

    PS: I started to write a PerlRegex to Elisp-Regex converter with regexes only.

    Re^3: [emacs] converting perl regex into elisp regex

    Still needs a decent test-coverage, but looks promising for me. (I'm searching for a good method to run automated tests from perl in emacs)

    Please tell me if you find a bug!

    One of the next versions shall also produce an elisp-version of the converter such that you can use perlsyntax directly from emacs.

  • PS: here another review plus screenshot http://www.newartisans.com/2007/10/a-regular-expression-ide-for-emacs.html

    Replies are listed 'Best First'.
    Re: [emacs] short review of regex-tool.el
    by ELISHEVA (Prior) on Sep 21, 2009 at 08:33 UTC

      When I want to test a regex, I usually open up an xemacs shell buffer (or even a regular command shell) and run the following eval loop to check regular expressions: perl -ne'print eval($_) . "\n"'. Then I type in lines like

      $re=qr{^abc}; 'abcdef' =~ $re; 'zabcdef' =~ $re; $x='Some long and ugly text'; $x =~ /long and ugly/; # and so on...

      Doing it in a shell buffer makes it easy to cut and paste values for either the text or the regex from other code. Then when I have a regular expression that does what I want I can cut & paste it back into my code very easily as well. An eval shell a lot gives me a lot of flexibility for playing "write-a-little, test-a-little".

      Yet you write with enthusiam "I like it!". Perhaps you could explain what a dedicated regex mode adds for you beyond what I just described? I'm probably too set in my ways, but I'm not seeing it.

      Now, what would be nice is Perl command buffer along the lines of the e-shell. That would convert even my minimal one-liner to start the eval loop into a mindless click. I wrote something like that for myself a year or so ago, but it seems to have disappeared in one of my periodic migrations from machine to machine.

      Best, beth

        Hi Beth,

        just some short answers, let me list some advantages in comparison to your method:

      • the matches in the string are highlighted (see screenshot)
      • you get an immediate update while you type and change the regex or text
      • you can manage larger (then one line) texts easier than from command prompt.
      • you can use all emacs commands/macros on the windows, especially undo and redo to get back and forward in your change history.

        Furthermore, from a emacs perspective, the elisp-code is _very_ short and simple, facilitating personal changes in just this module.

        (For instance I would like to run a command to take a snapshot of the three windows, and to append it persistently to my tests. And vice versa I would like to select just one of these tests again to continue interactive testing. One doesn't need deep knowledge of elisp to do this, since one can simply pipe any window's text in and out a perl-script to transform it.)

        Did you ever think (or try) to change the code in cperl-mode.el? It's a huge monolithic block of over 4000 lines, unfortunately it's not broken up into smaller modules... it's very hard to realize changes which will survive the next update.

        Of course your technique or the other mentioned in Composing regular expressions at runtime give experienced coders deeper testing possibilities for complicated code ... but if one is either new or in "brainless-mode" and doesn't want to code a loop it's a very good start. Talking about shell-support, you might wanna give sepia a try, it's full perl REPL integrated into emacs, of course with history functions.

        Furthermore it should be possible to tweak the perldebugger into a regex-tester with history cache, one can add aliases for personal commands and the docs mention pre and post commands to run with each prompt. (anyway I couldn't make the latter work using commands like <,> and { ...???)

        Cheers Rolf

        UPDATE: just found a note that it doesn't work with Xemacs :-( Sadly these incompatibilities are the main reason why I switched to Gnu Emacs a year ago, while I still recommend xemacs for newbies.

        Hi

        Now, what would be nice is Perl command buffer along the lines of the e-shell.

        I took a look into M-x eshell, in both emacsen, but I have problems to see what it's good for... the documentation is a stub and the functionality is barely better than with M-x shell ...???

        Anyway if you want a nice perl-shell embedded into emacs you should really try to install sepia, I simply took the debian install package and it worked straight away (well in GNU not Xemacs).

        Cheers Rolf