[Catalyst] Regex -- optional index.html
Bill Moseley
moseley at hank.org
Thu Mar 1 22:51:49 GMT 2007
I want to match these two (not using Chained, btw):
/training/webcasts/webcast_data/186/
/training/webcasts/webcast_data/186/index.html
But not this:
/training/webcasts/webcast_data/186/foo.html
$ perl -le 'print "YES" if "training/webcasts/webcast_data/186/index.html" =~ m!^training/webcasts/webcast_data/(\d+)/(index.html)?$!'
YES
$ perl -le 'print "YES" if "training/webcasts/webcast_data/186/" =~ m!^training/webcasts/webcast_data/(\d+)/(index.html)?$!'
YES
$ perl -le 'print "YES" if "training/webcasts/webcast_data/186/foo.html" =~ m!^training/webcasts/webcast_data/(\d+)/(index.html)?$!
I tried these:
Regex('^training/webcasts/webcast_data/(\d+)/(index.html)?$')
matches:
../186/index.html : yes
../186/foo.html : no
../186/ : no
../186 : no
Regex('^training/webcasts/webcast_data/(\d+)/?(index.html)?$')
matches:
../186/index.html : yes
../186/foo.html : yes
../186/ : yes
../186 : yes
Regex('^training/webcasts/webcast_data/(\d+)(/?index.html)?$')
matches:
../186/index.html : yes
../186/foo.html : yes
../186/ : yes
../186 : yes
--
Bill Moseley
moseley at hank.org
More information about the Catalyst
mailing list