home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
repltext.zip
/
repltext.doc
< prev
next >
Wrap
Text File
|
1999-05-11
|
4KB
|
119 lines
ReplText/2 v1.03 Freeware (c) 1999 by Robert Schroeder
Simple string replacing utility for text files
D e s c r i p t i o n
ReplText simply replaces all occurrences of one string pattern within a file
with another string pattern. It ain't grep!
I n s t a l l a t i o n
Put repltext.exe in a directory that shows up in the OS/2 path statement. Put
kbdvio32.dll in the same (or in a directory that is within the OS/2 libpath).
U s a g e
At the OS/2 command line, type:
repltext <textfile> [<pattern1> <pattern2>|/f:<patternfile>] [/c]
P a r a m e t e r s
<textfile> the name of the text file where patterns are to be replaced
<pattern1> the string to be searched for (optionally enclosed in double
quotes)
<pattern2> the string pattern1 is to be replaced with (optionally
enclosed in double quotes).
/c do distinguish between upper and lower case characters
/f:<patternfile> read patterns from file instead of getting them from the
command line
R u l e s f o r c o m m a n d - l i n e p a t t e r n s
Patterns may be enclosed in doube quotes. Patterns must be enclosed in double
quotes when they contain special characters which otherwise would be
interpreted by the OS/2 command line interpreter. Such characters include
the ampersand '&', the blank character ' ' and also the double quote '"'
itself: double quotes can be used when enclosed in more double quotes ("this
is a pattern containing "double quotes"").
Due to a restriction of the applied compiler, when specified as command line
parameters, string patterns MAY NOT CONTAIN angular brackets ('<' or '>'
characters), even when enclosed in double quotes, which of course is somewhat
annoying when replacing text in HTML files - that's the main reason why there
is the option to use a pattern file.
P a t t e r n f i l e
A pattern file is supposed to contain just the search pattern and the replace
pattern in two consecutive lines, one line each, no enclosing quotes. All
printable characters are allowed. A pattern may not exceed 255 characters of
length.
E x a m p l e s
repltext textfile.txt right left
repltext somefile "one plus two" "1 + 2"
repltext anotherfile.txt /f:pattern.fil /c
repltext index.html "color="#ff0000"" "color="#00ff00""
To replace all 'bold' tag pairs in an HTML file with 'italics' tag pairs, call
repltext file.html /f:btoi1.pat
repltext file.html /f:btoi2.pat
with btoi1.pat consisting of the two lines:
<B>
<I>
and btoi2.pat consisting of the two lines:
</B>
</I>
H i s t o r y
v1.0 (06-Feb-99) - First public release (erroneously showed v0.2 04-Feb-99)
v1.01 (10-Feb-99) - Repackaged with the previously missing kbdvio32.dll
v1.02 (10-May-99) - Bug fixed, new bug introduced :-(
v1.03 (11-May-99) - New bug fixed
F u t u r e p l a n s
all of which are classified 'well, maybe...', listed in my personal order of
preference:
Allow file specifications containing wildcards for searching and replacing
through a number of files in one pass.
Make it work recursively through subdirectories as well, optionally.
(Until then, both can easily and well be accomplished by using Kai Uwe
Rommel's 'forall'.)
Enable multiple search and replace patterns for one pass (which can easily
be accomplished by extending the pattern file).
If someone wants it, I'll make a gooey, erm, GUI version with the current
functionality and performance (which should be quite good for lines shorter
than 256 chars, but slows down significantly when there's a considerable
amount of longer lines. Though I must admit I haven't done any comparative
benchmarking yet). The task would be easy, so tell me if you want it.
C o n t a c t
The latest version of ReplText/2, more information of anything I might do for
OS/2 in the future (I'm working on a simple directory replication scheduler)
is to be found at <http://rob.schroeder.net/os2>.
I can be contacted by e-mail <rob@schroeder.net>.
D i s c l a i m e r
I don't guarantee anything, I won't be hold responsible for anything either,
and the copyright for this program is mine and only mine.
---
Have fun!
Robert Schroeder
rob@schroeder.net
http://rob.schroeder.net