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
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: 2 days ago @ 5:39 AM
Points: 428, Visits: 926
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 @ 9:57 AM
Points: 7,080, Visits: 12,571
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
Post #1307834
Posted Tuesday, May 29, 2012 9:04 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: 2 days ago @ 5:39 AM
Points: 428, Visits: 926
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