Scripted Find-Replace (suggestion)
Posted: Wed Aug 22, 2007 8:23 am
I would like to see a way to script multiple find-replace operations with TextPad's Regular Expressions (RE) engine. Macros are still un-editable and therefore not a viable solution.
My current solution for this is to use the GnuWIN sed.exe commandline utility, which works like a dream but has the following shortcomings:
Example-1
using sed to convert pipe(|) delimiters to tabs for pasting into MS-Excel.
Example-2
As above, but using a script-file with comments to describe each step.
where D:\sed\pipes_to_tabs.sed contains the following:
Quick tip: the sed syntax is "s/_find_/_replace_/" .. where "s" means "substitute".
Here's a thought. This kind of commandline utility that interfaces with the TextPad.exe might also provide the answer to the demand for editable macros! The editable script file in this case would simply specify the keystrokes .. and cleverly sidesteps the temptation to invent a yet another new macro language.
HTH
My current solution for this is to use the GnuWIN sed.exe commandline utility, which works like a dream but has the following shortcomings:
- The sed RE syntax is slightly different from TP's .. especially in the way that it handles line breaks (\n). TP's syntax is much easier!
- If I want to share my RE scripts with colleagues who already use TP, I have to install sed on their machines too, and highlight the differences with TP's REs.
Example-1
using sed to convert pipe(|) delimiters to tabs for pasting into MS-Excel.
Code: Select all
sed "s/^| *//;s/ *| */\t/g" D:\_isqlout1.txt
Example-2
As above, but using a script-file with comments to describe each step.
Code: Select all
sed -f D:\sed\pipes_to_tabs.sed D:\_isqlout1.txt
Code: Select all
s/^| *// # drop leading pipe
s/ *| */\t/g # replace all other pipes. "g" (global) means "don't stop after first replacement"
Here's a thought. This kind of commandline utility that interfaces with the TextPad.exe might also provide the answer to the demand for editable macros! The editable script file in this case would simply specify the keystrokes .. and cleverly sidesteps the temptation to invent a yet another new macro language.
HTH