Powershell Split with : but only once -


this question has answer here:

so, here's text file contains content this:

dbsnapshotidentifier : rds:xyz-new-2015-08-17-03-43 dbsnapshotidentifier : xyz-new-2015-08-17-04-43 dbsnapshotidentifier : rds:abc-2015-08-17-03-43 

my code:

foreach($line in $lines) { $del = $line -split ':' | select-object -last 1 } 

i trying read entire string (left of :), it's reading entire string in 2nd content. fails 1 , 3. 1 , 3, read value xyz-new-2015-08-17-03-43 , abc-2015-08-17-03-43 respectively (note rds:) omitted.

so, want entire string after first :, if multiple :'s found in string. tried -unique that, no luck. tried -last 2, coming 2 single words. need exact string rds:blah_blah_blah

can please me on this.?

why not?

"dbsnapshotidentifier : rds:xyz-new-2015-08-17-03-43" -split "dbsnapshotidentifier : " 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -