|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Yesterday @ 12:35 PM
Points: 345,
Visits: 605
|
|
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!
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 8:27 PM
Points: 6,735,
Visits: 11,788
|
|
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.
String.TrimEnd Method
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Yesterday @ 12:35 PM
Points: 345,
Visits: 605
|
|
Mystery solved. Ugh.
I managed to do what I wanted using Substring and IndexOf.
Thanks!
|
|
|
|