Checking if a Text Ends with Certain Characters

Share |

Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Powershell Plus

13 Free SQL Tools from Idera

Free Ebook: Mastering Powershell

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')

Twitter This Tip! ReTweet this Tip!

Posted Apr 04 2012, 06:00 AM by ps1
Copyright 2012 All rights reserved.