Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Wx Regex Tester

by Dog and Pony (Priest)
on Apr 10, 2002 at 08:55 UTC ( [id://157979]=note: print w/replies, xml ) Need Help??


in reply to Wx Regex Tester

I sincerely apologize for the godawful eval in the OnRunButton sub, but this was the only way I could come up with to safely execute a regex that might not compile.

You could always precompile the regexp:

my $regexp = qr/$retext/ or $resulttext->AppendText ("Error running regex : $errstr\n"), retu +rn; # regexp ok, code continues $ismatch = $testtext2 =~ /$regexp/;
... or something like that.

Also, instead of
while (defined (${++$i})){ push @match, ${$i} }
you could do something like this right off the bat:
@match = $testtext2 =~ /$regexp/;

Anyhow, I will try this program when I get home, where I have WxPerl installed. Since I am about to take the time to learn it a little myself, it is very nice to see that others are already using it!


You have moved into a dark place.
It is pitch black. You are likely to be eaten by a grue.

Replies are listed 'Best First'.
Compiling your regexes (boo)
by boo_radley (Parson) on Apr 10, 2002 at 17:56 UTC

    Dog and Pony sez :

    You could always precompile the regexp:

    I had a compiled regex in for a while, and it worked well for matches. But my understanding of compiled regexes led me to think I'd need something like :
    $testtext2 =~ s/$retext/$repltext/for substitutions.

    Which seems like I'd need to add in another text field for the replacement text, and then another text field (or checkboxes) for the flags. This would actually make it look quite similar to JEdit's RETester, in fact.

    I'll put it on the to do list.
      You could still use the precompiled regexp to do that, if that makes things better. :) $repltext on the other hand, should of course not be compiled.
      $testtext2 =~ s/$regexp/$repltext/
      Still haven't been home and awake long enough simultaneously... but I'll get there, if nothing else at the weekend. Stupid friends wanting to do non-nerd stuff. And outside! Where there is light from non-monitor sources! Heathens... :)
      You have moved into a dark place.
      It is pitch black. You are likely to be eaten by a grue.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://157979]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-25 07:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found