st33d
03-24-2007, 12:18 PM
I have this regex:
#! /usr/bin/perl -w
#/date/2007-02-22/ or /date/2007-02-22
#/index.php?date=2007-02-22 without a trailing slash
$s1 = "/date/2007-02-22/";
$s1 =~ s/date\/(.*)\/?/index.php?date=$1/;
print $s1;
But I can't get it to match the date folder with the optional slash at the end without including it in the replacement.
I want: /index.php?date=2007-02-22
not: /index.php?date=2007-02-22/
Is there a way of matching a string but not including it in the substitution?
#! /usr/bin/perl -w
#/date/2007-02-22/ or /date/2007-02-22
#/index.php?date=2007-02-22 without a trailing slash
$s1 = "/date/2007-02-22/";
$s1 =~ s/date\/(.*)\/?/index.php?date=$1/;
print $s1;
But I can't get it to match the date folder with the optional slash at the end without including it in the replacement.
I want: /index.php?date=2007-02-22
not: /index.php?date=2007-02-22/
Is there a way of matching a string but not including it in the substitution?