Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Regular Expression GUI?

by major tom (Novice)
on Apr 10, 2002 at 01:44 UTC ( #157925=perlquestion: print w/replies, xml ) Need Help??
major tom has asked for the wisdom of the Perl Monks concerning the following question:

Is there any graphical tools available for evaluating (perl) regular expressions? Something a'la MS Word's "Search and replace" type program with regular expression support would be REALLY nice.. Then it would be possible to QUICKLY see what the regexp actually does on some test data.. and it would save me ALLOT of debugging time.. Thanks for all help. Regards, Tom

Replies are listed 'Best First'.
Re: Regular Expression GUI?
by impossiblerobot (Deacon) on Apr 10, 2002 at 02:01 UTC
    ActiveStates's Komodo IDE for Perl (and other languages) does this. It was the only Komodo feature I really liked.

    They may still have a free version available for download.

    Impossible Robot
      Dominus wrote the code that ActiveState used for their regex debugger. It's available for download on his website:

      Of course, as he says: "Rx is not yet a complete, end-user application; it is a kit for building such applications," so it's probably not what the original poster is looking for. Just an interesting side-note.

      - Matt Riffle

Re: Regular Expression GUI?
by lachoy (Parson) on Apr 10, 2002 at 02:20 UTC

    The pretty nifty (and free as in beer/cost) editor JEdit has a RETest plugin that works pretty well. Despite what you may think from the name, it's an all-purpose editor, not just a Java editor.

    M-x auto-bs-mode

      JEdit is a nifty editor, but the engine that JEdit's regex tool (RE Tester) employs has several differences from perl's -- in some cases, this makes it impossible (or just annoying :) ) to compare RETester's results with perl's interpretation of a given regex.

      Here's some differences, right from the gnu.regexp documentation, included with the plugin :
      Unsupported Syntax Some flavors of regular expression utilities support additional escape sequences, and this is not meant to be an exhaustive list. In the future, gnu.regexp may support some or all of the following:

      (?:...) pure grouping operator (Perl5)
      (?=...) positive lookahead operator (Perl5)
      (?!...) negative lookahead operator (Perl5)
      (?#...) embedded comment (Perl5)
      (?mods) inlined compilation/execution modifiers (Perl5)
      \G end of previous match (Perl5)
      \b word break positional anchor (Perl5)
      \B non-word break positional anchor (Perl5)
      \< start of word positional anchor (egrep)
      \> end of word positional anchor (egrep)
      [.symbol.] collating symbol in class expression (POSIX)
      [=class=] equivalence class in class expression (POSIX)

      Additionally, I've seen it act rather odd when using .* without an EOL anchor.

        Very true. However, I'd imagine the plugin will be modified in the future to use the JDK 1.4 built-in java.util.regex instead of the external gnu.regexp library. The built-in library includes (according to the 4th ed. of Java in a Nutshell):

        (?:...) (?=...) (?!...) (?<flags>:...) \G \b \B

        Since it's open-source, I'd imagine this would get done sooner rather than later :-)

        M-x auto-bs-mode

GUI, Schmooi
by Fletch (Chancellor) on Apr 10, 2002 at 03:07 UTC

    Don't forget the versatile perl -de 0. Throw a test string in $_ and then just throw succesive iterations of x /foo/ at it until you've got your regex. See perldoc perldebug for more info.

Re: Regular Expression GUI?
by belg4mit (Prior) on Apr 10, 2002 at 03:05 UTC
    RegExplorer looks promising, if they ever support perl regular expressions (been keeping my on them for awhile). There are a few links to similar programs @ the bottom of the page.

    perl -pe "s/\b;([mnst])/'\1/mg"

Re: Regular Expression GUI?
by jwest (Friar) on Apr 10, 2002 at 20:32 UTC
    The visual-regexp package does this, and quite nicely. I'm very, very happy with it so far, and I've been using it intensively for the last six months or so.

    It can be found at

    -><- -><- -><- -><- -><-
    All things are Perfect
        To every last Flaw
        And bound in accord
             With Eris's Law
     - HBT; The Book of Advice, 1:7
      Yeah, this was EXACTLY what I was looking for.. What a great tool! Thanks for all help!
Re: Regular Expression GUI?
by young_david (Friar) on Apr 10, 2002 at 02:06 UTC
    ActiveState's Komodo has a cool regex toolkit. The toolkit will help you build, edit and debug your regular expressions. Check it out

Re: Regular Expression GUI? (boo)
by boo_radley (Parson) on Apr 10, 2002 at 08:01 UTC
Re: Regular Expression GUI?
by Mongo (Initiate) on Apr 10, 2002 at 20:27 UTC
    As numerous people have mentioned, the Komodo IDE includes a regex debugger based on mark-jason dominus's backend. I'd like to toot my own horn and point out a purl perl alternative:

    ReBug: A regular expression debugger in perl...I gave a talk on it at TPC5. The paper, and the application can be found here:

Re: Regular Expression GUI?
by Anonymous Monk on Apr 10, 2002 at 14:54 UTC
    The best GUI for this kind of thing is IMHO a web page; I have one at - the script behind it is about 1 page of Perl...
Re: Regular Expression GUI?
by zentara (Archbishop) on Apr 10, 2002 at 21:15 UTC
    What about the old standard?
    #!/usr/bin/perl use warnings; print "Please enter your test pattern \n"; chomp($pattern = <STDIN>); print "Please enter your test strings, 1 at a time,\n"; print "if a match occurs, your pattern will be echoed.\n"; while(<>){ # print if m!your pattern here!; print if m!$pattern!; }
Re: Regular Expression GUI?
by rbc (Curate) on Apr 10, 2002 at 19:01 UTC
    Take a look at the text_demo script that comes with Tk800.023 ...
    #!/usr/bin/perl -w use Tk; require Tk::Text; my $top = MainWindow->new; $top->option('add','*Text.background'=>'white'); my $t = $top->Scrolled('Text',"-relief" => "raised", "-bd" => "2", "-setgrid" => "true"); my $m = $t->Menu(); $m->add("command", "-label" => "Open", "-underline" => 0, "-command" => \&sayopen); $m->add("command", "-label" => "Close", "-underline" => 0, "-command" => \&sayclose); $m->add("separator"); $m->add("command", "-label" => "Selection", "-underline" => 0, "-command" => \&showsel); $m->add("separator"); $m->add("command", "-label" => "Exit", "-underline" => 1, "-command" => \&doexit); $t->pack(-expand => 1, "-fill" => "both"); $t->tag("configure", "underline","-underline","on"); $t->insert("0.0", "This window is a text widget. It displays one or m +ore lines of text and allows you to edit the text. Here is a summary of the things you can do to a text widget: 1. Insert text. Press mouse button 1 to set the insertion cursor, then type text. What you type will be added to the widget. You can backsp +ace over what you've typed using either the backspace key, the delete key, or Control+h. 2. Resize the window. This widget has been configured with the \"setG +rid\" option on, so that if you resize the window it will always resize to a +n even number of characters high and wide. Also, if you make the window narrow you can see that long lines automatically wrap around onto additional lines so that all the information is always visible. 3. Scanning. Press mouse button 2 in the text window and drag up or do +wn. This will drag the text at high speed to allow you to scan its content +s. 4. Select. Press mouse button 1 and drag to select a range of characte +rs. Once you've released the button, you can adjust the selection by press +ing button 1 with the shift key down. This will reset the end of the selection nearest the mouse cursor and you can drag that end of the selection by dragging the mouse before releasing the mouse button. You can double-click to select whole words, or triple-click to select whole lines. 5. Delete. To delete text, select the characters you'd like to delete and type Control+d. 6. Copy the selection. To copy the selection either from this window or from any other window or application, select what you want, click button 1 to set the insertion cursor, then type Control+v to copy the selection to the point of the insertion cursor. You can also bind commands to tags. Like press button 3 for menu "); &insertwtag($t,"here","underline"); $t->tag("bind","underline","<3>", [sub { shift; shift->Post(@_)},$m,Ev +(X),Ev(Y)] ); $t->bind("<Any-Enter>", sub { $t->focus }); $t->Subwidget('text')->OnDestroy(sub { print "Destroyed!\n"; print $t- +>get('1.0','end') }); Tk::MainLoop; sub insertwtag { local($w,$text,$tag) = @_; my $start = $w->index("insert"); print "start=$start\n"; $w->insert("insert",$text); $w->tag("add",$tag,$start,"insert"); } sub sayopen { print "Open something\n" } sub sayclose { print "Close something\n" } sub showsel { my @info = $t->tagRanges('sel'); if (@info) { print "start=$info[0] end=$info[1]\n" } } sub doexit { die "'die' no longer exits" }
Re: Regular Expression GUI?
by simon.proctor (Vicar) on Apr 10, 2002 at 08:24 UTC
    You could write a Java applet/application using JDK1.4 and build a regex checker that way. The new regex package claims to be Perl compatible.
Re: Regular Expression GUI?
by BUU (Prior) on Apr 10, 2002 at 03:08 UTC
    Textpad Is a truly wonderful text editor, supports multi document classes, syntax highlighting, plus regular expression find, and find-replace. Its just kewl.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://157925]
Approved by belg4mit
and the leaves swirl about...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2017-06-24 08:51 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (557 votes). Check out past polls.