Skip to content

Instantly share code, notes, and snippets.

@b4tman
Created August 16, 2017 07:12
Show Gist options
  • Save b4tman/e81f0f0811b5455f542f66d0b9674ea1 to your computer and use it in GitHub Desktop.
Save b4tman/e81f0f0811b5455f542f66d0b9674ea1 to your computer and use it in GitHub Desktop.
сумма по строкам
[CmdletBinding()]
param(
[parameter(Mandatory=$true, Position=1)]
[string]$Text
)
function SReplace($str)
{
[string]$ret = $str
[string[]] $Del = "`n,`r,`t, ,`",`",`',`'," -split ","
$Del += [char]([byte]160)
$Del | Foreach-Object -Process { $ret = $ret -replace $_, ""}
$ret = $ret -replace ",","."
return $ret
}
[string[]] $lines = $Text -split "`n"
[double] $sum = 0
$lines | Foreach-Object -Process {
$sum += [double] (SReplace $_)
}
return $sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment