Checking if a Text Ends with Certain Characters

by Apr 4, 2012

You can always use the String method EndsWith(). Just make sure you convert the text to lower-case first to avoid case-sensitive comparison.

This will check whether the file name ends with '.pdf':

PS> "somefile.PdF".toLower().EndsWith('.pdf')
True

Twitter This Tip! ReTweet this Tip!