PowerTip: Determine What Character a String Starts With

Doctor Scripto

Summary: Use Windows PowerShell to determine what character a string starts with.

Hey, Scripting Guy! Question How can I use Windows PowerShell to show me if a string starts with a particular letter (this also needs to be
           case sensitive)?

Hey, Scripting Guy! Answer Use the StartsWith method from the String class, and supply the character to the method. It will return
           a True or False Boolean value, for example:

PS C:\> "string".StartsWith("s")


PS C:\> "string".StartsWith("S")



Discussion is closed.

Feedback usabilla icon