function cut {
param(
[Parameter(ValueFromPipeline=$True)] [string]$inputobject,
[string]$delimiter='s+',
[string[]]$field
)
process {
if ($field -eq $null) { $inputobject -split $delimiter } else {
($inputobject -split $delimiter)[$field] }
}
}
PS C:> 'hi:there' | cut -f 0 -d :
hi
PS C:> 'hi:there' | cut -f 1 -d :
there
PS C:> 'hi:there' | cut -f 0,1 -d :
hi
there
PS C:> 'hi:::there' | cut -f 0 -d :+
hi
PS C:> 'hi there' | cut
hi
there