[Catalyst] Regex -- optional index.html
Jon
jon+catalyst at youramigo.com
Thu Mar 1 23:18:40 GMT 2007
How about this:
m!^training/webcasts/webcast_data/(\d+)/(index.html|$)!
On Thu, 2007-03-01 at 14:51 -0800, Bill Moseley wrote:
> 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
>
>
>
>
More information about the Catalyst
mailing list