APM: Regex Question

Thomas L. Shinnick tshinnic at io.com
Mon Jun 26 03:08:30 PDT 2006


At 01:29 AM 6/26/2006, David Bluestein II wrote:
>Okay I want to do the following in this order:
>
>s~(/nexres/reservations/application[^"])+~VALUE$1~g
>s~/nexres/reservations[^"]+~VALUE2~g
>
>How do I construct REGEX #2 so that it doesn't match the result from
>#1? I need something like:
>
>/nexres/reservations([^"]+) where $1 is not like '/a.*'
>
>I know there is something like that, but don't remember the syntax.

If you wanted a negative look-ahead ...

     while( <DATA> ) {
         chomp;
         printf "Saw '%s'\n", $_;
         if ( s~(/nexres/reservations/application[^"]+)~/maybe1$1~g ) {
             printf "RE 1 matched\n";
         }
         if ( s~(/nexres/reservations(?!/application)[^"]+)~/maybe2$1~g ) {
             printf "RE 2 matched\n";
         }
         printf "Now '%s'\n", $_;
     }
__DATA__
http://reservation.indo.com/nexres/reservations/application=foo
http://reservation.indo.com/nexres/reservations/input_dates.cgi?src=10011323"

Outputs:
Saw 'http://reservation.indo.com/nexres/reservations/application=foo'
RE 1 matched
Now 'http://reservation.indo.com/maybe1/nexres/reservations/application=foo'
Saw 
'http://reservation.indo.com/nexres/reservations/input_dates.cgi?src=10011323"'
RE 2 matched
Now 
'http://reservation.indo.com/maybe2/nexres/reservations/input_dates.cgi?src=10011323"

g'nite

>Thanks-
>
>David
>-----------------------------------------------------------------------
>David H. Bluestein II
>President & Lead Developer         dbii at interaction.net
>ii, inc.
>http://www.interaction.net
>      -- Specializing in Interactive, Database Driven Websites --
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/austin/attachments/20060626/8b0191bd/attachment.html 


More information about the Austin mailing list