It looks like TrimStart considers argument as a set of characters and removes any of those characters from the start of the string.
Here's one option to remove a string prefix: $a = '0-24.254.16.172.in-addr.arpa' $prefix = "0-24." if ($a.StartsWith($prefix)) { $a = $a.Substring($prefix.Length) } Or you could use something with IndexOf to find the position of the first ".": $a = $a.Substring($a.IndexOf(".")+1) Edward From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com] On Behalf Of Mote, Todd Sent: Tuesday, October 04, 2016 11:22 AM To: scripting@lists.myitforum.com Subject: [scripting] powershell trimstart? Stumbled across this in the last couple of days, can anybody tell me what's going on? I have a string: '0-24.254.16.172.in-addr.arpa' I need to remove the '0-24.' From the front so I thought, trimstart would get me what I needed, however ('0-24.254.16.172.in-addr.arpa').trimstart('0-24.') returns 54.16.172.in-addr.arpa If I take out the dot and run ('0-24.254.16.172.in-addr.arpa').trimstart('0-24') it returns .254.16.172.in-addr.arpa I know I could use substring to get the results I need, or even 2 trimstarts, ('0-24.254.16.172.in-addr.arpa').trimstart('0-24').trimstart('.') , but why does it trim the '2' when I have the dot in there and trims what it's told when it's not? what's special about a dot inside a string? I've seen the same behavior with front slash "/". Double vs single quotes doesn't seem to matter. I also thought maybe it needs to be escaped, but putting a backtick in doesn't change the outcome either. Any ideas? Todd