Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

TrimEnd Expand / Collapse
Author
Message
Posted Monday, May 28, 2012 11:55 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld 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!



Post #1307419
Posted Tuesday, May 29, 2012 8:59 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

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
Post #1307834
Posted Tuesday, May 29, 2012 9:04 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld 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!



Post #1307838
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse