One-Liner: Fun with Multi-line Blocktext and –Split/.Split()

The title is an oxymoron: I’m going to show a one-liner on how to deal with multi-line blocktext.  To start with, I’m using ‘blocktext’ to mean: $blocktext = @" This is an example using @" .. "@ "@; which is known from Unix-dom as ‘heretext’ and what I simply call ‘multi-line strings, below.  Yeah,, that’s…

0

One-Liner: Padding a Number with Leading Zeroes

I’m putting this here only because I’m tired of searching for it.  How to pad an integer with leading zeroes is trivial.  1..16 | % { "{0:D2}" -f $_ } And padding a float with trailing zeroes is more of the same: $i = 2; (1..10) | % { “{0:F5}” -f $i; $i = $i…

0

Splitting a Hex-Encoded String into Pairs of Hex Characters (a.k.a. To Pull a Noah)

Simple enough task: I have a hex-encoded string and need to decode it.  Now, we all know that to encode a string to hex is to cast each [char] to [int], then shove it through the "{0:X}" format specifier, then concatenate all the strings. $string = "The quick brown dog"; [string]::Join($null, ([char[]]$string | % {…

1