Find a substring in a string with PowerShell and trim

powershell, scripting

Solution

 $positionSlashA = "Test test test test test test /abc test test test".IndexOf("/a")
 $result1 = "Test test test test test test /abc test test test".Substring($positionSlashA)
 $positionfirstspace = $result1.IndexOf(" ")
 $result1.Substring(0, $positionfirstspace)

Problem

I am trying to trim a string with PowerShell. Let's say you have the following string: Test test test test test test /abc test test test I want to 'find' the '/a' in the string and ultimately get the "abc" by finding the next space. Is that doable with PowerShell?

Original source