More Related Content
Similar to 20120518 power shell_文字處理及輕量測試 (20)
More from LearningTech (20)
20120518 power shell_文字處理及輕量測試
- 11. Get-Content String
Param($Path)
$lines = Get-Content -Path $Path
$newLine = [System.Environment]::NewLine
$content = [String]::Join($newLine,$lines)
$content
- 13. Extract-Number
# .ExtractNumbers.ps1 Test.txt
Param($path)
$nums = Get-Content $path
$numberMatcher = [regex] "d+"
$matches = $numberMatcher.Matches($nums)
foreach ($match in $matches)
{
if ($match.Success)
{
$number = $match.Groups[0].Value
Write-Host "number:$number"
}
}