Find And Replace
- Originally submitted by Ben Noeske, Harvard University Library, on June 13, 2003. Later updated by wiki editors.
The Find and Replace functionality was (I think) first introduced in the beta version dated 15 June 2001. The following information is based on testing I did with version 2.0h. The functionality was enhanced in version 5.0a, 31 March 2008.
See also the official OCLC Find page.
The Find and Replace lines are placed after the host/domain lists in a resource entry in the ezproxy.cfg file.
The Find line specifies the text to be replaced. The text on this line must match exactly the text in the page being proxied. That means the same number of spaces, the same use of case, etc. I do not believe there is anything like a wildcard matching operator or any other fancy pattern matching stuff.
Use the Replace line to specify the text that replaces the text on the Find line. The Replace line can take advantage of several special operators. More operators are listed at the official OCLC Find page.
- ^H – inserts the proxy server's hostname (e.g. ezpserver.university.edu) in this position.
- ^D – inserts the proxy server's domain (e.g. university.edu) in this position.
- ^L – inserts the proxy server's domain with a leading period (e.g. .university.edu).
- ^Psome_host_ezproxy_knows^ – placing ^P and ^ around some_host_ezproxy_knows will cause proxying to be applied to some_host_ezproxy_knows and the resultant string to be inserted. This is useful for making things look like EZproxy links that wouldn't otherwise be transformed by EZproxy (i.e. they don't appear as a link in an HREF tag or don't have a leading "http://" in the text of the page). For example:
T some db U http://www.somedb.com DJ somedb.com Find http://www.somedb.com Replace http://^pwww.somedb.com^
Without this Find/Replace, EZproxy would leave http://www.somedb.com untouched (it would look like http://www.somedb.com in your browser, and you might wonder why it wasn't proxied until you saw the underlying coding). With the Find/Replace, EZproxy would make it look proxied (i.e. replacing www.somedb.com with something like 80-www.somedb.com.ezpserver.university.edu).
Note: the some_host_ezproxy_knows doesn't have to belong to this same entry in the configuration file. In this example it could've actually been www.someotherdb.com in the Find/Replace lines, as long as there was an entry somewhere in the cfg file that applied to www.someotherdb.com. It's not likely that there would be such a situation where you would really want to do that.
Look through the recommended database configurations at http://www.oclc.org/us/en/support/documentation/ezproxy/db/ to see examples of these in use. Or, if you have a test version of EZproxy available, go ahead and play with them.
I don't know what the limits are for the lengths of strings in the Find/Replace lines. I've been able to use strings over a hundred characters long in a Find line without problem.
Multiple Find and Replace lines
Multiple Find and Replace lines can be included in each database configuration entry in the ezproxy.cfg file. Each Find/Replace pair will be applied to all pages that match that entry.
Note: Find/Replace does not cascade. If you have the following:
Find x-string Replace y-string Find y-string Replace z-string
x-string would be replaced with y-string, but that y-string would not then be replaced with z-string. Of course, any y-string in the original page would be replaced with z-string.
If there are two database entries that match a given page, the Find/Replace lines from the entry that comes first in the cfg file will be applied. Thus if a Find/Replace is not happening when you expect it to, you should check your config file for an earlier entry that matches the page you are looking at.
Example: T some db U http://www.somedb.com D somedb.com Find http://www.somedb.com Replace http://^pwww.somedb.com^ T some related db U http://srdb.somedb.com H srdb.somedb.com # the following Find/Replace won't ever take place because all pages # for this resource will actually be processed by the above entry for some db. Find 'somedb.com' Replace '^d'
Find and Replace occurs before proxying
If you were to cause a host in an HREF tag to be replaced with a host that is described by an entry somewhere in the ezproxy.cfg file, the string replacement will happen first and then that link will be transformed into its proxied form. Again, situations where you would want to do this are rare. I'm just including it for completeness of documentation.
Find/Replace can be a powerful tool, but it is also somewhat fragile because minor cosmetic changes by the resource vendor (the addition of an extra space, capitalizing something, etc.) that normally make no functional difference can cause a Find/Replace line to stop working. And like any extra processing you ask EZproxy to do, Find/Replace lines will create more load on your server. Of course, this probably won't be an issue unless you egregiously overuse the functionality, but it's something to keep way in the back of your mind.