$file = "d:\workspace_vs1\owrainfo_www\owrawww\src\main\resources\templates\sub04_03.html" $enc = [System.Text.Encoding]::UTF8 $c = [System.IO.File]::ReadAllText($file, $enc) # ---- 1. Head: add board.css ---- $h_old = "`r`n 보도자료`r`n" $h_new = "`r`n 보도자료`r`n `r`n `r`n `r`n`r`n" $c = $c.Replace($h_old, $h_new) Write-Host "1. Head: $([bool]($c -match 'board.css'))" # ---- 2. Depth1 breadcrumb label + links (8 tabs before button/ul, 9 tabs before inner) ---- $tab8 = "`t" * 8 $tab9 = "`t" * 9 $tab10 = "`t" * 10 $crlf = "`r`n" $d1old = "$tab8$crlf" + "$tab8" $d1new = "$tab8$crlf" + "$tab8" $before = $c.Length $c = $c.Replace($d1old, $d1new) Write-Host "2. Depth1: replaced=$($c.Length -ne $before)" # ---- 3. Depth2 breadcrumb links ---- $d2old = "$tab8" $d2new = "$tab8" $before = $c.Length $c = $c.Replace($d2old, $d2new) Write-Host "3. Depth2: replaced=$($c.Length -ne $before)" # ---- 4. Search form: div -> form with th: attributes ---- # Use regex to replace the whole board-search-wrap div through section 1 comment $sfNew = @"
"@ # Escape $ in replacement string for [regex]::Replace $sfNewEsc = $sfNew.Replace('$', '$$') $before = $c.Length $c = [regex]::Replace($c, '(?s)
[\s\S]*? "@ $galleryNewEsc = $galleryNew.Replace('$', '$$') $before = $c.Length $c = [regex]::Replace($c, '(?s)
[\s\S]*? "@ $pgNewEsc = $pgNew.Replace('$', '$$') $before = $c.Length $c = [regex]::Replace($c, '(?s)
[\s\S]*?