May 28, 2012 at 11:55 am
Can someone please explain why ccra and project (lines 1 and 3) return ccr and projec, respectively, while the other two examples return what I would expect, ccrb and projecs?
"ccra_Data.mdf".trimend("_Data.mdf") #1
"ccrb_Data.mdf".trimend("_Data.mdf") #2
"Project_Data.mdf".trimend("_Data.mdf") #3
"Projecs_Data.mdf".trimend("_Data.mdf") #4
Thanks!
May 29, 2012 at 8:59 am
TrimEnd accepts a char array, not a string. This is a more explicit way to write the code:
[char[]]$charArray = @('_','D','a','t','a','.','m','d','f')
"ccra_Data.mdf".TrimEnd($charArray) #1
"ccrb_Data.mdf".TrimEnd($charArray) #2
"Project_Data.mdf".TrimEnd($charArray) #3
"Projecs_Data.mdf".TrimEnd($charArray) #4
Notice the letters I bolded above are contained in the char array.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
May 29, 2012 at 9:04 am
Mystery solved. Ugh.
I managed to do what I wanted using Substring and IndexOf.
Thanks!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply