Help me with Notepad++
-
I have a result of SQL query with two colums Name and ROW_ID
For example here is the output I have pasted in notepad++
Agreement Expire Workflow 1-TD3H3Y
Auto CF Asset Pricing Procedure 1-TD3H4U
Auto Complete 1-TD3HBR
BIP AttachEntity Report Generation 1-TD3HC8
BIP Create Report Output 1-TD3HEC
My requirement is to replace space with _spc and the last row_ID should have double quotes. before the ROW_ID it hsould have = sign. For example it should look like this
Export_spcAssignment_spcData=“1-7ASH7K”
The actual nam e is Export Assignment Data 1-7ASH7K -
Curious that you’re not doing that in your SQL query, but I’m assuming you want to do that using Find/Replace in Notepad. Other assumptions: 2) The column divider appears to be a space, but also could be a tab. 3) The words in the Name column will always begin with a letter and never a number (for example, this value would not be present in the Name column: Auto 1CF Asset Pricing Procedure). 4) Only a single space separates the words in the Name column. 5) The ROW_ID column will always begin with a single digit and a hyphen and will never contain spaces. This could be incorrect, but based on your sample data, that seems reasonable.
So with your output open in Notepad++, open the Replace dialog (Ctrl+H works) and click the bottom radio button Regular expression. Also make sure the Match case checkbox is not checked. You’ll need to do 2 Replace operations. First, paste the next line into the Find what box:
[ ]([a-z]\S+)
(?# Space followed by letter followed by non-space chars)
and paste this into the Replace with box:
_spc\1
(?# _spc followed by stuff in parentheses)
Click the Replace All button and it should replace all spaces, except for the ones in front of the second column, with _spc.
Then paste this into the Find what box:
[ \t]+(\d-\S+)
(?# 1 or more spaces or tabs followed by a digit then a hypen then non-space chars)
and paste this into the Replace with box:
=“\1”
(?# =" followed by stuff in parentheses then by ")
Click the Replace All button and it should replace all spaces before column 2 with =" and put a " after the value.Obviously, check the result to make sure the assumptions were correct and nothing unexpected happened, but that should get you the result from your example.