-
Notifications
You must be signed in to change notification settings - Fork 1
/
todo_JoinOnNewLine-SplitNewline.ps1
54 lines (37 loc) · 1.19 KB
/
todo_JoinOnNewLine-SplitNewline.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'situation where you force split on nefwline, or join on, to always ensure code will run '
if ($false) {
Get-Command -Module ClassExplorer #| Join-String -sep "`n"
| Join-String { $_.Source, $_.Name -join '\' } -Separator "`n"
| Sort-Object
| ForEach-Object { $_ -split '\n' } # here
| Join-String -Sep ', '
function JoinOnNewline {
$_ -join "`n" # ex1
# any advantage to this?
$_ | Join-String -sep "`n" #ex2
# maybe ex2 doesn't have to finish processing, plus load entire list into memory
# vs ex2 which may (depending down the line) process as chunks in a stream
}
function SplitOnNewline {
$_ -split '\r?\n'
}
function PipelineSplitString {
<#
#>
}
function PipelineRegexSplit {
<#
#>
}
'nonsense example case
just sugar
'
$inputSample = 0..30
$inputSample -join ', ' | ForEach-Object { $_ -split ', ' } -join ':'
$Input2 = Get-ChildItem 'C:\Windows\'
h1 'ex:'
$inputSample -join ', ' -replace ', ', ':'
h1 'ex:'
$Input2 | Get-Random -Count 5 | Join-String -sep ', ' Name
0..30 -join ', ' -split ', ' -join "`n"
}