Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Determine What Character a String Starts With

$
0
0

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

True

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

False


Viewing all articles
Browse latest Browse all 3333

Trending Articles