Programming and design: Andrew Shelkovenko.
RQ Search and Replace is a shareware software. HomePage - http://mira.xeno.ru
You can download the latest version of RQ Search and Replace from http://mira.xeno.ru/rqsr.zip  or  http://mira.home.line1.ru/rqsr.zip 
Documentation -
http://mira.xeno.ru/helpe.zip


What's new
Batch search and replace in MS Word documents supports now !!!
Important note!

To provide search and replace operations in MSWord documents be sure that you close MS Word application !!!
Also set menu "View as" in "Plain text" mode !!!


Introduction

The program RQ Search and Replace is used to search and replace multiple text fragments in several files simultaneously.
Search and replace patterns are stored in the search and replace table. You don't need to fill the table manually. It is possible to open required file in the built-in editor, select a text fragment and copy&paste it into the table. The table can store multi-line text blocks. Use  search editor and replace editor fields to add or edit multi-line text blocks  in the search and replace table.

Here are key features of RQ Search and Replace

Screenshot of main Window


Quick start

1).Select a folder where SEARCH & REPLACE operations should occurs by clicking
on the Folder button in the upper right hand corner.
To specify only certain file types use the pull-down menu just below it.
If you want to include the subfolders that are below the specified folder click on the Include subfolders checkbox and select which subfolders you want to include in the Search & Replace operations.

2) If you want to open a specific file in the Build-In editor... double click on one of the files listed in the File List box (right hand panel).

3) Click on the cell in the first row of the "Find What" column and either... manually enter the text that you want to find or drag and drop from the Build-In editor.

4) Click on the cell in the first row of the "Replace With" column and either... manually enter the text that you want to replace the found text with or drag an drop from the Build-In editor.

5) Click on the cell in the first row of the "Object" column and select from the pull-down menu... what type of object to Search for.

6) Click on the cell in the first row of the "Mode" column and select from the pull-down menu... what type of mode to use for the Replace operation.

7) Repeat steps 3 - 6, in the next row down of each column... if you want to add more Search & Replace operations.

8) Put a checkmark in the "!!!" column, of each row, that you want to perform when you click the Start button.

9) When you are ready to begin the Search & Replace operation... click on the the Start button on the right hand side of the screen.

10) If the results, of the Search & Replace operation, are incorrect... select from the Backup menu, one of the Restore options.

Objects list

1. Text block -
single or multi-line text block.
2. Text string -
text block separated by CR+LF or LF symbols
3. Whole word -
whole word is part of text enclosed  one of the following chars -
cr,lf,./\| !@#$%^&*()+=-?><~`;:[]{}'
4. HTML tag.
5. Enclosed block - Enclosed block is part of text enclosed in specified chars sequences ("brackets").
6. MS Word objects -
text, special symbols, hyperlinks.

Following operations are supported:

For Text block, Whole word, Enclosed block.

Replace -
replacement of text block in selected files
Delete -
deleting of text block in selected files
Insert before -
inserting "replace pattern" before "search pattern"
Insert After -
inserting "replace pattern" after "search pattern"

 
For MS Word objects

Replace 


For strings

Replace  -
replacement of all strings, that contains "search pattern", by the "replace pattern"
Note, that full string will be replaced by "replace pattern"

Delete  -
deleting all strings that contains "search pattern"
Insert before  -
inserting "replace pattern" before string that contain "search pattern"
Insert after  -
inserting "replace pattern" after string contained "search pattern"
("replace pattern" can contain empty line for adding string before or after search pattern)

For HTML tags

Delete tag - deleting all tags that contains "search pattern"
Change attribute

Delete attribute
Add  attribute - Add  the attribute with given value. If attribute already exists - just set the new attribute value.
In upper case - set attribute value to upper case for attributes listed in replace cell only.
In lower case- set attribute value to lower case for attributes listed in replace cell only.

You can search for files within the specified Path. You should also specify mask. All files from the specified Path conterminous with the specified mask are processed. The manual search and editing of the loaded file is possible.

Objects description

1. Text block.

Text block is simple characters flow "as is".
Set Block object type in object column of search/replace grid

For example (in square brackets) 

[ple characters flow "a] - single line text block.

[ search for files within the specified Path. You should also specify mask. All files from the specified Path conterminous with the specified m]  - multi-line text block .

You can add and edit single- or multi-line text block in the search/replace table using the search or replace grid editors fields.
The found text block will be replaced by the text block from the Replace cell of the table.

2. Text string  

Set String  object type in object column of search/replace grid
Text string is part of text enclosed by CRLF or LF chars. When you press Enter in text editor CRLF chars added to the text and new string created.

For example:
Search cell contains pattern [color].
Replace cell contains pattern [there was color].

a). The  Mode cell contains [Replace

Program search all string that contains pattern [color], as

1 </div></span></ilayer></layer></iframe></noframes></style></noscript></table></script></applet></font>
2 <body bgcolor="#FFFFFF" text="#000000" link="#295181" vlink="#295181" alink="#660000">
3 <font color=#00ffff>BS_FLAT</font>
4 <style>

and then replace this strings by strings [there was color]. (full text from Replace cell)
2 and 3 lines contains pattern [color] and will be  replaced

Result is:

1 </div></span></ilayer></layer></iframe></noframes></style></noscript></table></script></applet></font>
there was color
there was color
4
<style>

b). The  Mode cell contains [Delete].

2 and 3 lines contains pattern [color] and will be  deleted

Result is:
</div></span></ilayer></layer></iframe></noframes></style></noscript></table></script></applet></font>
<style>

c). The Mode cell contains [Insert before]
Result is:
</div></span></ilayer></layer></iframe></noframes></style></noscript></table></script></applet></font>
there was color<body bgcolor="#FFFFFF" text="#000000" link="#295181" vlink="#295181" alink="#660000">
there was color<font color=#00ffff>BS_FLAT</font>
<style>

d). The Mode cell contains [Insert after]

Result is:
</div></span></ilayer></layer></iframe></noframes></style></noscript></table></script></applet></font>
<body bgcolor="#FFFFFF" text="#000000" link="#295181" vlink="#295181" alink="#660000">there was color
<font color=#00ffff>BS_FLAT</font>there was color
<style>

Note, that no  strings added to text, just the replace pattern added to beginning or ending  of found strings (i.e. strings, that contains search  pattern)
To add a new string you need add
clrf characters to replace pattern.

3. Whole word

(Set  Wholeword object type in object column of search/replace grid)

Whole word is part of text enclosed  one of the following chars -
cr - carriage return
lf - line feed
,./\| !@#$%^&*()+=-?><~`;:[]{}'
ht - hot tab

Usually whole word is part of text enclosed by spaces.

4. HTML tag.

(Set   HTML tag object type in object column of search/replace grid)

HTML tag is char sequences, similar to

<[ ]tag name[ ]attribute name[ ]=[ ]attribute value[ ][...] >

[ ]
- one or more white spaces
attribute name and attribute value is optional

[...]
- repeat (attribute name[ ]=[ ]attribute value[ ])
sequence.

Program search tags by search condition and changes found tags.

Tags search conditions.

You can set the tag search conditions
next :

1. Tag
Equivalence
Program searches for the same tag with the same attributes set.
Attributes order in tag, spaces are ignored.
In search cell you need insert tag and
EQU key, separated by <>
For example:

In search cell:
<IMG SRC="bluprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page">
<>EQU

All found tags with the same 5 attributes will be changed.

If you insert in search cell tag without attributes -   all the same tags without attributes will be found and changed.

2. AND condition
Program search the same tag, and it  must contains all attributes from search cell + any other attributes.
In search cell you need insert tag and
And key, separated by <>
For example:

In search cell:
<IMG 
WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"> <>And

All found tags, that contain this 4 attributes will be changed.

<IMG SRC="bluprev.gif"
WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page">
or

<IMG SRC="rev.gif"
WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page" >

but not

<IMG SRC="bluprev.gif" WIDTH = 62 HEIGHT = 32 BORDER = 0 ALT="Previous Page">

WIDTH = 62 not WIDTH = 32

<IMG SRC="bluprev.gif"
WIDTH = 32 HEIGHT = 32 BORDER = 0 >

attribute
ALT="Previous Page" not presents.

If you insert in search cell tag without attributes -   all the same tags with ANY attributes will be found and changed.

3. OR condition.

Required tag should comprise even one of attributes of search - attribute with the same value.
In search cell you need insert tag and OR key, separated by <>
.
For example - 
<script defer =1234><>OR
If you insert in search cell tag without attributes -   all the same tags with ANY attributes will be found and changed.

 4. And-NOT condition.

Required tag should NOT comprise NOT every of attributes of search - attribute with the same value.
In search cell you need insert tag and NOT key, separated by <>
If you insert in search cell tag without attributes -   all the same tags with ANY attributes will be found and changed.

5. Not -OR  condition

Required tag should NOT comprise even one of attributes of search - attribute with the same value.
In search cell you need insert tag and NOR key, separated by <>
For example - 
<script defer =1234><>NOR

6. By default search condition is OR

Tag operations

Next tag operations are possible:

1. Delete tag

Replace cell content - (delete keys) Operation
Empty  (by default) delete start tag and corresponding end tag
ALL   delete start tag, corresponding end tag and all text (and other tags) enclosed in this tag.
ALL - delete only  text enclosed in this tag.

You can choose delete keys from drop-down list in replace cell. Select cell, then click on the cell again  and click on appeared arrow.

Change attribute
1. In search cell insert tag with attribute that need be changed.
2. Program search tags by search condition.
3. In found tag program search attribute by its name.
4. If attribute present - program change attribute value by value from replace cell.

For example

Search Replace
<meta http-equiv="Content-Type"> charset=windows-1251

Result:
Ex.1
Old tag   <META http-equiv="Content-Type" content="text/html">
New tag <META http-equiv="Content-Type" content="text/html">
No changes, because no charset attribute presents.

Ex.2
Old tag
<meta http-equiv="Content-Type" charset=windows-1250>
New tag
<meta http-equiv="Content-Type" charset=windows-1251>
Charset attribute value changed by value from replace cell
 

2. Replace attribute - value of attribute is replaced on given.
More in detail.
1. Searched tag, satisfying to a condition of search
2. In found tag the attribute is searched, which name coincides with given in a cell of replacement.
3. Set attribute value to the given in a replacement cell

For example 1.
Search cell
<meta http-equiv="Content-Type">
Replace cell charset=windows-1251
Will be search tags meta, contains attribute http-equiv="Content-Type"  and if tag contains also attribute  charset, then charset value will
be set to
windows-1251

For example
2.
Search cell
<meta  charset=windows-1251><>AND
Replace cell
charset=koi8-r

Will be search tags meta, contains attribute charset=windows-1251  and  attribute  charset  value will be set to koi8-r.

3. Delete attribute

4. Add  attribute
Add  the attribute with given value. If attribute already exists - just set the new attribute value.

5. In upper case - set attribute value to upper case for attributes listed in replace cell only. If in replace cell char * presents - set all attribute value to upper case.

6. In lower case

Note.

1. Double (and more ) white spaces replace by single spaces.
2. Quotes and apostrophes is equal
i.e attribute values
onClick="this.setHomePage('http://www.ru'); return false;"
onClick='this.setHomePage("http://www.ru"); return false;'
onClick=this.setHomePage('http://www.ru'); return false;
is equal.

5. Enclosed block


Enclosed block is part of text enclosed in specified chars sequences ("brackets"). This "brackets" can be multichars.
Program search first  sequence ("bracket") , then second "bracket" and change text block beetwen last char positin of first bracked and first char position of second bracket.

For example:
First bracket is AAA char sequence.
Second bracket is BBB char sequence.

All text is

 1234AAAmy textBBBnot my text

Program found that my text is appropriated to search terms.

If there are many "brackets" in text:

 1234AAAmy AAAAA teBBBx zzzzAAAAAzzz tBBBnot me text

Program found that my AAAAA te is first appropriated block and  AAzzz t is second appropriated block.

You can use the second bracked the same as first bracked.
For example:
First bracket is AAA char sequence.
Second bracket is AAA char sequence too.
In this case:

 1234AAAmy qAAAAA teBBBx zzzzAAAAAzzz tBBBnot me text

the first appropriated block is my q
the second appropriated block is AA teBBBx zzzz

For delete mode you can set search pattern in replace cell. If pattern is contained in found "ecnclosed block"  - this block will be changed.
For example:
Note.
When Enclosed block object type selected two fields added to Search cell.

Search Replace
AAA BBB ZZZ


Line1   AAAwwwwwwBBB   

Block wwwwww  will not be deleted, because it not contain  pattern ZZZ

Line2   AAAww   bzzzBBB

Block  ww  bzzz  will  be deleted, because it contain  pattern ZZZ

Example of Search and replace grid




6. MSWord objects

You can use text blocks, words, special characters or wildcards, hyperlinks.
Select from Object column drop-down list "MSWord" item and then click on Object or Mode cell.
Next window will be showed.



This window is similar to Find and Replace window in MSWord.
You can test search patternt using MSWord and then paste it in "Find what" and "Replace with" in this window.
You can copy and paste multiline text from MSWord and then press "Fill from clipboard" button.
Formatted text will be converted into plain text with special symbols and fill out to focused field "Find what" or "Replace with"
To search and replace hyperlinks just Copy hyperlink from MSWord document and paste it in "Find what" field.
Then paste it again in "Replace with" and edit as you wish.
Hyperlinks usually seems like this
MiraSoftware <http://mira.xeno.ru/rqsr.html

where MiraSoftware is Text-To-Display property and http://mira.xeno.ru/rqsr.html is Address property.

You can open
MSWord document in build-in  editor.
Use menu View as - As is. Then double click in document file in the right file list and select Open in popup window.
Document will be opened in
build-in  editor. You can select and copy-paste text.
To save changes press Ctrl-S.

Important note!
To provide search and replace operations in MSWord documents be sure that you close MS Word !!!
Also set menu View as in Plain text mode !!!

 

How to use

1. Specify a file or files
This panel allows to explore the folders, to view and to edit list of files to process. Press the button LOpen.bmp (1654 bytes) to explore and select the folders.
Select file mask.

filelst.png -- select folder

-- select or type new mask of the files to show on the Folders panel.

-- create the file list including files in subfolders. When checked, File List window will be opened. (See below).
All checked files from this list will be processed.

You can exclude some files by unchecking.


-- list of files that will be processed.
 
When "Include subfolders" is unchecked only files from this list will be processed

When "Include subfolders" is checked  File List window will be opened.
Subfolders separated by background colors.

Also you can select file mask by mouse right button click


Choose extension.. - view file with extension as highlighted file
Only this file - view only highlighted file
Refresh file list - refresh file list

By pressing the button LOpen.bmp (1654 bytes) you can open a directory tree panel to choose the folders. The "hot" directories can be chosen and kept in the appropriate combo box.

The chosen file can be started (if it has registered type) by double click on a line with a name of a file under the menu.


2. Insert the patterns into the search and replacement string grid.
Choose required operations - Replace, Delete etc, and objects - block, string, whole word etc.

Only checked lines  will processed in operations of search and replacements.
It is possible to fill in the table in the any order.

To fill in the string grid is possible in several ways.

For manual search in the editor text it is necessary to input search pattern into a field and to press the button Search.

If the input field is empty, the fragment of the text which is taking place in the grid editor will be searched. For preservation of a fragment of search it is necessary after input to press a key Enter. In the further fragment of search it is possible to choose from the dropping out list. The result of search will be displayed in the editor of a file by highlighting of the found fragment.

To begin search and replacement process press the Start button. If the data in the string grid of search and replacement are incorrect, the warning message will be showed.

The results of search process are displayed in the log editor and on the log panel. The process of search can be stopped, having pressed the button Stop. This button can be used and in other cases, for example for a stop of loading of the very large file etc.

Menu


Additional functions

You can convert text files into html (with the syntactic highlighting for sources files .asm, .bas, .c, .pas)
Keywords are stored in files asm.key, bas.key, c.key, pas.key.
You can add custom keywords in this files.

For building a table of contents it is necessary to choose in the list only files of a HTML-format. Otherwise file of a table of contents can be not generated.


If you have any comments  about RQ Search and Replace please direct its to

mira@mail.line1.ru or  diakin@narod.ru to Andrew Shelkovenko.