Hi,
I want to know the blue word section (powershell code) with the same effect as the QM code,
foreach and replace nested
Thanks in advance for any advice and help
david
________________________________________________________________________________
$s = @'
function A([Paragraph]$p1, [Paragraph]$p2){
'{A}'
}
function BB([Paragraph]$p1){
'{BB}'
}
function CCC(){
'{CCC}'
}
function Main([string[]]$args)
{
$A($p1, $p2)
$BB($p1)
$CCC()
}
'@
$b = $s | Select-String 'function ([a-zA-Z_][a-zA-Z0-9_]*\().*\)' -AllMatches |
foreach{
$_.Matches |
foreach{
'${0}' -f $_.Groups[1].Value
}
}
$s -split '\r?\n' |
foreach {
foreach ($b_ in $b)
{
if ($_ -match [regex]::Escape($b_))
{
$_ = $_ -replace '\(', ' ' -replace '\)' -replace ',' -replace '^(\s*)\$','$1'
}
}
$_
}
I want to know the blue word section (powershell code) with the same effect as the QM code,
foreach and replace nested
Thanks in advance for any advice and help
david
________________________________________________________________________________
$s = @'
function A([Paragraph]$p1, [Paragraph]$p2){
'{A}'
}
function BB([Paragraph]$p1){
'{BB}'
}
function CCC(){
'{CCC}'
}
function Main([string[]]$args)
{
$A($p1, $p2)
$BB($p1)
$CCC()
}
'@
$b = $s | Select-String 'function ([a-zA-Z_][a-zA-Z0-9_]*\().*\)' -AllMatches |
foreach{
$_.Matches |
foreach{
'${0}' -f $_.Groups[1].Value
}
}
$s -split '\r?\n' |
foreach {
foreach ($b_ in $b)
{
if ($_ -match [regex]::Escape($b_))
{
$_ = $_ -replace '\(', ' ' -replace '\)' -replace ',' -replace '^(\s*)\$','$1'
}
}
$_
}