Re: Search/Replace
by Jan Theodore Galkowski <jtgalkowski(at)alum.mit.edu>
|
Date: |
Sat, 02 Sep 2000 12:30:51 -0400 |
To: |
Virginia Blalock <virginia(at)visionsnet.com> |
Cc: |
hwg-software(at)hwg.org |
In-Reply-To: |
visionsnet |
|
todo: View
Thread,
Original
|
|
At 09:53 AM Saturday 09/02/2000 -0500, Virginia Blalock wrote:
>I have a rather large HTML file that I need to do some massive search and=
=20
>replacements on. I need to replace one text string with another(as usual)=
=20
>BUT part of the string is different. I guess I am looking for a search and=
=20
>replace that uses wildcards instead of exact text string search/replace.=20
>Is there such an animal out there?
Virgina,
Hi. Yes. I'm not sure what platform you do the edits on,
but if you're running one of the UNIXes or BASH (see=20
http://www.cs.washington.edu/homes/voelker/ntemacs.html#shell-bash)
you're in much better shape: Use emacs (see http://www.emacs.org/)
or (g)awk. If you're running Win*, you're still not out of
luck, just that your choices are more limited. There are emacs
and gawk implementations for Win* (eg, cygwin:=20
http://support.cygnus.com/cygwin/index.html), and implementations
for the Mac exist but aren't as numerous.
In short, what you want is something that searches for a string
pattern, matches a token to a part of it, and rewrites the string
substituting the match in the appropriate place. These strings
are typically specified by things called "regular expressions"
which are described online and in a (good) book by O'Reilly.
Emacs has a command (query-replace-regexp) which implements
this. Gawk (or awk) is a string rewriting language and processor
that allows regular expressions as string descriptors.
For Windows, there are other alternatives than these classic
solutions. For instance -- and only for instance, despite how
highly I think of the solution -- an editor called TSE/32 Pro
by Semware (http://www.semware.com/) has a search-and-replace
which accepts regular expressions using a slightly different
syntax (and better, IMO) than emacs or gawk.
For Macintosh, there is a large and powerful editor called
Nisus Writer that has its own excellent regexp search and
replace. (See http://www.nisus.com/.) There's also BBEdit
which also has a regular expression-based search and replace,
and a powerful HTML editing capability. (See
http://www.bbedit.com/products/bbedit/key.html.)
IMO, it's short-sighted to argue "I need to only do this
one thing, so why should I get/buy one of these and take
the trouble to learn it?" If you have one such search-and-
replace to do, you'll have another one to do in not too
long.
Hope this helps.
--jtg
______________________________________________________________________
Jan Theodore Galkowski =BAo=BA ::dsotm:: demiourgos(at)smalltalk.org
algebraist.com/ "Walk tall, talk Small" jtgalkowski(at)alum.mit.edu
PGP fingerprint: 2757 F86D AA51 677D 38D7 964B 9A8D 7852 A494 3790=20
HWG: hwg-software mailing list archives,
maintained by Webmasters @ IWA