Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,29 @@
|
|||
function Split-String ([string]$String, [char]$Separator, [char]$Escape)
|
||||
{
|
||||
if ($String -notmatch "\$Separator|\$Escape") {return $String}
|
||||
|
||||
[bool]$escaping = $false
|
||||
[string]$output = ""
|
||||
|
||||
for ($i = 0; $i -lt $String.Length; $i++)
|
||||
{
|
||||
[char]$character = $String.Substring($i,1)
|
||||
|
||||
if ($escaping)
|
||||
{
|
||||
$output += $character
|
||||
$escaping = $false
|
||||
}
|
||||
else
|
||||
{
|
||||
switch ($character)
|
||||
{
|
||||
{$_ -eq $Separator} {$output; $output = ""; break}
|
||||
{$_ -eq $Escape} {$escaping = $true ; break}
|
||||
Default {$output += $character}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($String[-1] -eq $Separator) {[String]::Empty}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
Split-String "one^|uno||three^^^^|four^^^|^cuatro|" -Separator "|" -Escape "^" | ForEach-Object `
|
||||
-Begin {$n = 0} `
|
||||
-Process {$n+= 1; "{0}: {1}" -f $n, $_}
|
||||
Loading…
Add table
Add a link
Reference in a new issue