Hello,
I have many files containing text like:
%ENDSECTION{name="operatoraddrsection1"}%
%ENDSECTION{name="operatoraddrsection2"}%
%ENDSECTION{name="operatoraddrsection3"}%
There might be any number of these lines (each with a different number at the end, depending on how many are in that particular file) .
I want to add a line of text just after the LAST one of these in each file by using search and replace -- but ... how can Textpad find which is the last one?
Thanks!
finding the last instance of a string
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Try this:
Ctrl+End to take the cursor to the end of the file.
Open the Find dialog box and enter the following in the Find what section:
(%ENDSECTION{name="operatoraddrsection[0-9]+"}%)
Check the Conditions for Text and Regular expression and the Direction as Up
Press Find next. This should find the last instance in the file.
Open the Replace dialog box. Type in the Replace with section:
\1\nthe text I want to insert
Press Replace
I have used POSIX regular expression syntax, which can be selected from the Editor page of the Preferences dialog box.
If the text you want to insert is the same for every file, you could record a macro using the same steps described above, and then run this on each file.
I hope this helps.
Ctrl+End to take the cursor to the end of the file.
Open the Find dialog box and enter the following in the Find what section:
(%ENDSECTION{name="operatoraddrsection[0-9]+"}%)
Check the Conditions for Text and Regular expression and the Direction as Up
Press Find next. This should find the last instance in the file.
Open the Replace dialog box. Type in the Replace with section:
\1\nthe text I want to insert
Press Replace
I have used POSIX regular expression syntax, which can be selected from the Editor page of the Preferences dialog box.
If the text you want to insert is the same for every file, you could record a macro using the same steps described above, and then run this on each file.
I hope this helps.
Helios Software Solutions