I look around and can't find anything. I would like to trim the string without shortening the short word. Like an excerpt.
$string = "This is my string" 9 = "This is m"
Ideally, I would like "This is my"
"This is my"
$string.Substring(0, $string.IndexOf(" ", 9))
To do what you want, that is, to start with the number of the character that you give it, looks for the next space and shortens the short line there.
Do you mean $string.Substring(0,$string.lastindexof(" "))?
$string.Substring(0,$string.lastindexof(" "))