Search and Replace : Java Glossary

*0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ (all)
The JDisplay Java Applet displays the large program listings on this web page. JDisplay requires an up-to-date browser and Java version 1.7+, preferably 1.8.0_25. If you can’t see the listings, or if you just want to learn more about JDisplay, click  here for help. Use Chrome for best results.
The CurrCon Java Applet displays prices on this web page converted with today’s exchange rates into your local international currency, e.g. Euros, US dollars, Canadian dollars, British Pounds, Indian Rupees… CurrCon requires an up-to-date browser and Java version 1.7 or later, preferably 1.8.0_25. If you can’t see the prices in your local currency, Troubleshoot. Use Chrome for best results.

logo Search and Replace
Sr32.exe/Sr64.exe 7.2 Last revised/verified: 2014-09-19 is Funduc’s utility to search and replace strings in files. I use the newer versions of the prorgam, SR PE and SR BE hundreds of times a day. I can’t think of any other program where I so thoroughly got my money’s worth except for SlickEdit which I got free.
Magic Replacement Strings Command Line Use
Tips Three Variants
Gotchas RFEs
Menu Icons Links

Magic Replacement Strings

The utility has regular expressions, scripts, and magic replacement strings like:
Search and Replace Magic Replacement Strings
%%srfound%% Returns the current search string.
%%srfound %% - Special A special form of the %%srfound%% operator can be used to strip specified characters from the search hit. The form is: %%srfoundcharacters to remove specified here%%, where characters to remove specified here is one or more characters which, if present in the search hit, will be removed from the replace. Example: Upon a replace operation, %%srfoundiex %% removes the letters i, e, x, and <spaces> from the search hit.
%%srpath%% Returns the path (without filename) of the current file.
%%srfile%% Returns the file name (without path). This can be used to customise generic boilerplate with the file name.
%%srfiledate%% Returns the current date stamp of the file. This is the date prior to a replace made by Search and Replace.
%%srfiletime%% Returns the current time stamp of the file. This is the time prior to a replace made by Search and Replace.
%%srfilesize%% Returns the file size prior to the replace made by Search and Replace.
%%srdate%% Returns the current date of the machine.
%%srtime%% Returns the current time of the machine.
%%srprepend%%
%%srappend%%
Used in Search and Replace scripts — The search string will be prepended or appended to the file as a literal string.
%%envvar=fruit%% returns the contents of the SET fruit=strawberry environment variable. This can be used to customise boilerplate.

Tips

Gotchas

I find the icons hard to tell apart. They are too fussy and too much alike. I wish I could replace them even with simple coloured shapes.

Funduc Icons

They are stored internally as 16 × 16 sections of a single image. They mean: search, replace, touch, file operations, case sensitivity, search subdirectories, word mode, regex, search zips, ignore whitespace, html mode, view context, copy results, view as HTML, print, script, options, help, about. The icons might look like:

I can’t think of better icons than the letters for now. If letters were used, they should use a variety of colours.

Command Line Use

You can use SR from the command line. There is extensive documentation in the help to describe how the various switches are used, but it is hard to find.
Search and Replace Command Line Parameters
/b Backup path, e.g., /Bc:\temp\srbackup. See Replace Options
/i Case Insensitive. Note that this option is the reverse of what the user interface shows. If not specified, Case Sensitive is assumed.
/x Regular Expression. If not specified, it is assumed off. If you want to search for binary characters, specify /x.
/w Match Whole Word (ignored if Regular Expression is used). If not specified, it is assumed off.
/sstring Search String to use. This automatically starts a Search. If the string contains spaces or / characters, enclose it in double quotes as with the /r switch above. If the string contains " characters, use the \ character to denote the literal. For example, if your search string contains both quotes and a space, as in Windows 95, you would use, Sr32 /s\Windows 95\"" Note: To do a File Find from the command line, specify /s but supply no string.
/rstring Perform a replace. This can be used either with scripts via /c switch (see below) or by itself with a replace string. If the string contains spaces or / characters, enclose it in double quotes as in /s below. If the string contains " characters, use the \ character to denote the literal. For example, if your replace string contains both quotes and a space, as in Windows 98, you would use, /r\Windows 98\""
/d Search Subdirectories. If not specified, it is assumed off.
/pC:\*.ini;*.txt Path to search with mask(s) appended after the \. If no path or masks are specified, the last program default is used. The /p switch command line parameter accepts partial paths, including .. characters, e.g., /Pc:file.txt or /Pfile.txt or /P..\test\file.txt or /P\file.txt.
/oresults.txt Output file to send the search results to. If not specified, the last program default is used (this is specified in the Options dialog).
/cscript.srs Script file to use. Use /s to initiate a search. If the script involves a replace, use /r to initiate a replace.
/n No Prompt. Works only with /r. Note: This resets program options so you should manually restore prompts settings after using /n (see Options dialog). I could not get this to work.
/t Perform a Touch on the files specified. You can specify a date/time stamp or use the current date/time (default). For the 32-bit version, the user’s date format is used and the HH:MM:SSam/pm format is used for time. For the 16-bit version, the same time format is used but the MM/DD/YY or MM/DD/YYYY format is used for date. The Touch dialog is only displayed if the date/time stamp passed on the command line is in the wrong format. The date and time must be enclosed in double quotes to work properly, e.g., sr32.exe /pc:\work\*.* /t01/01/00 1:00:00am.
/u Disables the user interface. Use this to run the program silently. There will be no Taskbar entry. For no user interface during replaces, disable replace confirmations with /n or the Prompt_flag=2 setting in your script. Note: If you also don’t want error messages about file locking or replacements in binary files, use Quiet Mode in Options|General.
/q Quit after operation. The Search & Replace window will close after the operation is completed. I could not get this to work.

Three Variants

PayPal, but you have to ask for special instructions. The website is not set up to handle PayPal as yet another credit card.

There are now three versions of Search/Replace. The two new ones can still run the old scripts:

Search/Replace Variants
Variant Cost
CurrCon Applet needs Java 1.7 or later to display prices in your local currency.
Notes
Classic Search/Replace $25.00 USD The original Search/Replace. This is what I have used for many years. It handles ad hoc search/places, simple scripts called favourites, and complex scripts with multiple search/replace pairs and multiple wildcards to describe what files to process. The main thing wrong with it is the Regexes use a proprietary Funduc prefix syntax. I find that confusing since I use postfix SlickEdit and Java Regex schemes as well. It is the most difficult to learn to use of the three.
Replace Studio BE (Business Edition) $30.00 USD A streamlined version of the original tuned for running scripts. It can be hard to find things in the original, such where you control whether subdirectories are scanned too. In this version, everything is no more than one click away, and more logically organised. It is easier to see the entire search/replace string, and you no longer have to click Apply to make your changes stick. To do one-off searches, you compose a simple one search/replace pair script that you don’t save. It can use the old classic scripts, but it then converts them to *.srx format, at type of XML (extensible Markup Language). This means you can now manipulate your scripts with ordinary XML tools. Unfortunately, my sort/dedup utility, SortSRS does not handle these new scripts. It also means that trailing spaces on search value are safe from trimming if you tweak the script in a text editor. It can optionally export the results as nicely formatted HTML to view in a browser. It can deal with .docx, pptx, and .xlsx files which the original could only do in binary mode. It can modify files inside zips.
Replace Studio Pro $30.00 USD A streamlined version of the original tuned for ad hoc searches or running simple favourites-style scripts with a single from-to pair. It looks much like the original, without the script editor. You can compose simple scripts with pairs of search/replace.

Power users might want to use both Studio BE and Studio Pro. You get a massive discount if you do that. All three are trialware, so you can try them out to see which one or which combination best fits your needs. Compare Classic, Pro and Business Editions. The trial version suppresses replaces after the first five, so it is just useful for evaluation, not getting useful work done to properly test it.

I bought bought versions thinking I would use mostly the business edition, but the opposite is true.

The BE and pro versions use a new XML-based script format. This makes it easier to generate scripts and programmatically manipulate scripts. It also regularises the ways of quoting awkward characters. Unfortunately, Funduc did not update the icons for the new versions.

RFE (Request For Enhancement)

These are the improvements would like to see. The most important items are at the top of the list.

  1. Java-style postfix regex syntax.
  2. Cache results of last N searches so if you repeat a search, it does not need to rescan files that have not changed since last time.
  3. Let you pause a search/replace for manual touch-up, then carry on where it left off.
  4. An alternate set of icons that are easier for someone with less than perfect vision that are more distinctive and less detailed or a way to let you install your own set of icons.
  5. Search expressions separated by | are very slow. Anything over eight expressions in an or list are unusably slow. Oddly, splitting them up into multiple search/replace expressions speeds things up. Other search engines don’t have this problem. The | should be implemented as a finite state machine as is done in parser-generators, so that each new character encountered selects a state that concerns itself with only a narrower set of the possibilities in the or. Another way of looking at the problem is the logic needed is like Boyer-Moore, an algorithm that seaches for several strings simultaneously examining only few of the characters in the data parsed.
  6. Let you scroll the results to view them while they are still being generated.
  7. The menus should not be scrollable with the mouse buttun. I get far too many false scrolls.

Perhaps if others asked too, they might reconsider.


This page is posted
on the web at:

http://mindprod.com/jgloss/searchreplace.html

Optional Replicator mirror
of mindprod.com
on local hard disk J:

J:\mindprod\jgloss\searchreplace.html
logo
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.
no blog for this page
IP:[65.110.21.43]
Your face IP:[54.87.134.127]
You are visitor number