# Replace operation

With Advanced Find and Replace you are still able to make normal one-string replacements. But it also offers a great possibility to replace entire paragraphs of text.

You may insert you Java script right after the </BODY> or any other text.

For instance, you have the document:

<HTML><BODY>

<P>Hello World</P>

</BODY></HTML>

Note: please, use Ctrl-C, Ctrl-V for clipboard operations for copying text from source file and inserting text in Text to Find and Replace by Text fields from clipboard. If you type several lines of text manually, you have big chance make an error and AFR may not find text for replacements.

You may perform following actions with this document:

Replace

For instance, replace text Hello World by Good morning World!

Insert before

For instance, insert two strings right before <P>Hello:

<H2>A Test</H2>

Then you will have the document:

<HTML><BODY>

<H2>A Test</H2>

<P>Hello World</P>

</BODY></HTML>

Insert after

For instance insert the same text after <P>Hello World</P>, then you will have:

<HTML><BODY>

<P>Hello World</P>

<H2>A Test</H2>

</BODY></HTML>

Insert between

This can be very useful when you need to replace some fragment of text between other fragments.

For instance you have banners on your pages. The code in the banners is slightly different in the pages.

<!-- banner begin -->

banner's code

<!-- banner end -->

So put <!-- banner begin --> in Text to Find, new banner's code into Replace/Insert by Text and <!-- banner begin --> into Ending With.

AFR will replace your old banner's code by new one.

Tip: if you need to delete all your banners, make two steps:

1. Insert between with empty Replace/Insert by Text field.

2. Delete operation, where you put result of the operation in first step.

Delete

Use it to delete the text specified in Text to Find field.

Just Find

This maybe used to find several lines of text in the document. It just finds it and shows in search results. It does not make any changes in the source documents.

It's very useful perform Just Find operation before Replace/Insert/Delete operations. Only when Just Find shows correct list of files where you want to make changes, then you are sure and you may perform Replace/Insert/Delete.

Note: You may use Case sensitive option. For instance, use may uncheck this option and specify just hello world text in previous examples.

Insert Top

If Search for field is empty, then Insert Top action inserts text specified in Replace with field at the the top of each file.

If Search for field is not empty, then Insert Top action inserts text specified in Replace with field at the the top of each file that has at least one occurrence of Search for field.

Insert Bottom

If Search for field is empty, then Insert Bottom action inserts text specified in Replace with field at the the bottom of each file.

If Search for field is not empty, then Insert Bottom action inserts text specified in Replace with field at the the bottom of each file that has at least one occurrence of Search for field.

Cyclic Replace From File

Use this action if you want to replace the same Search For text by different occurences of Replace With text taken from file. For example you have source file:

+++++ hello ++ world
this is +++++
test
file+++++ end
+++++

and you want to replace the same search for text: +++++ by different occurencies from file, for example, named cyclicfile.txt:

AAA
BBBB
CC

So, after execution of Cyclic Replace From File action you will get the following file:

AAA hello ++ world
this is BBBB
test
fileCC end
AAA

For using this action you should put full path to cyclic file into Replace with field, for example, C:\Program Files\Advanced Find and Replace\test\cyclicfile.txt*

And seach for text (++++ in our example) into Search for field.

If you check option Make only one cycle for Cyclic Replace From File action program will make only one cycle, so the resulting sample file will be:

AAA hello ++ world
this is BBBB
test
fileCC end
+++++