Ensuring string is at end of string/file
Posted: Mon Aug 11, 2003 1:55 pm
Say I have a filter expression of:
\.[hH][tT]([mM][lL]?)
because I need to be concerned whether the extension is lowercase, uppercase, or mixed case. Hopefully this expression covers filenames with an extension of:
.htm, .html
with the various permutations of capitalization. However, I want to ensure that this is at the end of the string/filename. I suspect that:
case 1: \.[hH][tT]([mM][lL]?)$
won't work because maybe it just looks for "m" and "ml" (and their permutations of capitalization) at the end of the string/filename and not the whole string at the end of the string/filename. Would I have to instead use:
case 2: (\.[hH][tT]([mM][lL]?))$
But then maybe case 1 would work since all the characters must be contiguous. To simplify and not bother about case sensitivity, would:
\.ht(ml?)$
work or would I need to use:
(\.ht(ml?))$
to guarantee .htm or .html was at the very end of the string/filename?
\.[hH][tT]([mM][lL]?)
because I need to be concerned whether the extension is lowercase, uppercase, or mixed case. Hopefully this expression covers filenames with an extension of:
.htm, .html
with the various permutations of capitalization. However, I want to ensure that this is at the end of the string/filename. I suspect that:
case 1: \.[hH][tT]([mM][lL]?)$
won't work because maybe it just looks for "m" and "ml" (and their permutations of capitalization) at the end of the string/filename and not the whole string at the end of the string/filename. Would I have to instead use:
case 2: (\.[hH][tT]([mM][lL]?))$
But then maybe case 1 would work since all the characters must be contiguous. To simplify and not bother about case sensitivity, would:
\.ht(ml?)$
work or would I need to use:
(\.ht(ml?))$
to guarantee .htm or .html was at the very end of the string/filename?