Same result..  ☹
('0-24.254.16.172.in-addr.arpa').trimstart(‘0-24\.’)



From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com] On 
Behalf Of CESAR.ABREG0 .
Sent: Tuesday, October 4, 2016 1:37 PM
To: scripting@lists.myitforum.com
Subject: Re: [scripting] powershell trimstart?


I'm guessing uses regex to parse it. The period say to select one character 
after the phrase. Try adding \. to your string.

On Tue, Oct 4, 2016, 11:29 AM Mote, Todd 
<mo...@austin.utexas.edu<mailto:mo...@austin.utexas.edu>> wrote:
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



Reply via email to