A million ways to skin a cat, to be sure, I was mostly interested in the why and Chris got me there.
So it’s not a string match it’s a character array match. I tested it, if you put ‘0’, ‘-‘, ‘2’, ‘4’, and ‘.’ in any order it removes matches to any of those single characters, not the order of the characters of the “string” I pass it. I just happen to be unlucky that the third octet of that reverse DNS address started with a ‘2’. That seems counter intuitive for what the name of the method is, but I guess I can see why. You learn something new every day. This was it today for me. Thanks guys, I knew somebody would know! Todd From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com] On Behalf Of It's Mike Mitchell Sent: Tuesday, October 4, 2016 2:25 PM To: scripting@lists.myitforum.com Subject: Re: [scripting] RE: powershell trimstart? $addr = '0-24.254.16.172.in-addr.arpa' -split '\.',2 Then $addr[1] contains the meat. On Oct 4, 2016, at 12:05 PM, Chris Muster <chr...@nowmicro.com<mailto:chr...@nowmicro.com>> wrote: TrimStart() removes characters from the start of a string, so when you pass ‘0-24.’, you’re actually telling it to remove the characters ‘0’, ‘-‘, ‘2’, ‘4’, and ‘.’ from the start of the string. ‘5’ is the first character that doesn’t match, so that’s where the new string starts. See the MSDN article for more details: https://msdn.microsoft.com/en-us/library/system.string.trimstart.aspx From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> [mailto:listsad...@lists.myitforum.com] On Behalf Of Mote, Todd Sent: Tuesday, October 4, 2016 1:22 PM To: scripting@lists.myitforum.com<mailto: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