I have the following lines in a file:
pc_cc_text$fx_review1 CONSTANT VARCHAR2(100) := 'For Company Review'; -- AD_PRT_AUTH_(MSP)pc_cc_text$fx_review2 CONSTANT VARCHAR2(100) := 'For Dept Review'; -- AD_PRT_AUTH_(ADX)
I need to format them as follows:
WHEN 'pc_cc_text$fx_review1' THEN 'For Company Review'WHEN 'pc_cc_text$fx_review2' THEN 'For Dept Review'
How to do this in PowerShell?
This is what I have tried so far:
(Get-Content FILE | where {$_ -match ':='} | where {$_ -notmatch '^--'} | ForEach-Object{("'" + $_ -split ";|--")[0,1] -join ''}) -replace 'CONSTANT[^ ]' -replace 'VARCHAR2[^ ]' -replace ':=', 'THEN ' -replace '^', 'WHEN '
This prints:
WHEN 'pc_cc_text$fx_review1 THEN 'For Company Review'WHEN 'pc_cc_text$fx_review2 THEN 'For Dept Review'
It is almost correct but the second single tick on the second column needs to be added. How to do this?