来练练手- $s= @'
- Key 1
-
- Hello 1
- World 1
- ---
- Key 2
-
- Hello 2
-
- World 2
- ---
- Key 3
-
- Hello 3
- World 3
-
- '@
- $pattern = "(([\S\s]+?)[\r\n]+---[`r`n]?)"
- $out = ( $s + "`r`n---" | Select-String -Pattern "(([\S\s]+?)[\r\n]+---[\r\n]?)" -AllMatches ).Matches.Value -replace "---" ,''
- $ss = 'sss '
- $arr=@()
- $n = 65
- $out |% {
- $a,$b = ($_ -replace '[\r\n]+', "`n" |Select-String -Pattern "(.+?)\n" -AllMatches).Matches.Value
- $c = [char](++$n - 1)
- $arr += "{$c}={$($c)v}[]"
- "$ss $c="
- ' ' + $a.trim()
- ' ' + $($b -join " ").trim()
- "sss ${c}v="
- ' ' + "${c}v.ffff"
- }
- 'sss kv=@' + '"{0}"' -f ($arr -join '').TrimEnd("[]")
- 'DDD(kv)'
复制代码
|