PowerTip: Return Specific Number of Letters from String

Doctor Scripto

Dr Scripto

Summary: Use Windows PowerShell to return a specific number of letters from a string.

Hey, Scripting Guy! Question  How can I use Windows PowerShell to easily to retrieve the first two letters from a string?

Hey, Scripting Guy! Answer  Use the SubString method from a string, and then specify the starting the position and the number
           of letters to return, for example:

PS C:\> ("string").Substring(0,2)

st

0 comments

Comments are closed.