Page 1 of 1

Ensuring string is at end of string/file

PostPosted: Mon Aug 11, 2003 1:55 pm
by Vanguard
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?

PostPosted: Mon Aug 11, 2003 2:52 pm
by Smite
$ isn't a modifier for other parts of the string, so being placed after brackets or just characters shouldn't make any difference.