lib/Str/Str.ps1
using namespace Microsoft.VisualBasic function Fst ($s,$sep=' ',[switch]$rev) {(Brk-2 $s $sep -rev:$rev)[0]} function Fst-Chr ($s) {Left $s 1 } function Fst-OrAll ($s,$sep=' ',[switch]$rev) {(Brk-1 $s $sep -rev:$rev)[0]} function Instr ($s,$sub,$fmPos=1,[switch]$rev){if($rev){return InstrRev $s $sub};[Strings]::Instr($fmPos,$s,$sub,[CompareMethod]::Text)} function InstrRev ($s,$sub,$len=-1) {[Strings]::InStrRev($s,$sub,$len,[CompareMethod]::Text)} function LasChr ($s) {Right $s 1} function Left ($s,$len) {[Strings]::Left($s,$len)} function Len ($s) {[Strings]::Len([string]$s)} function LTrim ($s) {[Strings]::LTrim($s)} function Mid ($s,$pos,$len=-1) {if($len-lt0){[Strings]::Mid($s,$pos)}else{[Strings]::Mid($s,$pos,$len)}} function Quote ($s,$quote) {$1,$2=Brk-Quote $quote;$1+$s+$2} function Right ($s,$len) {[Strings]::Right($s,$len)} function RTrim ($s) {[Strings]::RTrim($s)} function Snd ($s,$sep,[switch]$rev) {(Brk-1 $s $sep -rev:$rev)[1]} function Snd-OrAll ($s,$sep,[switch]$rev) {(Brk-2 $s $sep -rev:$rev)[1]} function Spc ($nSpc) {[Strings]::Space($nSpc) } function Trim ($s) {[Strings]::Trim($s) } function Rmv-LasChr($s) {if(Is-Empty $s){""}else{Left $s ((Len $s)-1)}} function Rmv-FstChr($s) {if(Is-Empty $s){""}else{Mid $s 2}} function Fst-Chr ($s) {Left $s 1} function Las-Chr ($s) {Right $s 1} |