Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Perl Regex Question

Name: Anonymous 2012-02-26 1:44

I've been using /e to execute code with something I've captured in regular expressions. Like so:

$string =~ s{(tExT)}
            { do_something($1) }eg;


However, I've been wondering if there's anything else I can do in there. Like for example, could I use if-statements in there?

Name: Anonymous 2012-02-26 2:29

Why don't you try it instead of asking?

Name: Anonymous 2012-02-26 2:35

>>2
Because I tried it, and it didn't work. But I was wondering if there was a way, but I was just doing it wrong.

Using $& to try to check for matches was tricky, but I got it now.

Name: Anonymous 2012-02-26 2:44

>>3
Well if it didn't work then it doesn't work I guess.

Gee did you ever learn the Scientific Method when you went to school or didn't you go at all?

Name: Anonymous 2012-02-26 4:12

It looks like you need Perldoc.
http://perldoc.perl.org/perlre.html

Name: Anonymous 2012-02-26 4:25

Name: Anonymous 2012-02-26 12:41

Name: Anonymous 2012-02-26 15:32

>>4
You don't even have any idea what he's talking about. Why do non-programmers come to /prog/ and pretend to be hardass.

Don't change these.
Name: Email:
Entire Thread Thread List