Skip to main content.
home | support | download

Back to List Archive

Re: Problem with "replace"

From: Bill Moseley <moseley(at)not-real.hank.org>
Date: Fri Nov 30 2001 - 17:02:47 GMT
At 08:26 AM 11/30/01 -0800, John Elser wrote:
>I've got two questions that are some what related.
>
>1) replace doesn't seem to work.  Here is a my conf file:

Here's my test on the current version.  There was a problem lately with the
parsing of the parameters, so likely you got caught with a version that was
broken.  Anyway, here's something to test:

> cat c
ReplaceRules replace ../swish-e/src/ foo


> ./swish-e -c c -i ../../swish-e/src/1.html -v 0 -T properties regex
Indexing Data Source: "File-System"

Original String: '../../swish-e/src/1.html'
replace ../../swish-e/src/1.html =~ /../swish-e/src//foo/: Matched
replace 1.html =~ /../swish-e/src//foo/: No Match
  Result String: '../foo1.html'
          swishdocpath: 6 ( 12) S: "../foo1.html"
          swishdocsize: 8 (  4) N: "0000000000107"
     swishlastmodified: 9 (  4) D: "2001-11-29 04:48:07"
Indexing done!

The results look ok, but the -T regex trace looks weird to me (I'm not sure
why it's doing the second "replace".

>2) How do I display only my file name as the link to my document.  Right
now, I'm using "swishdocpath" and it is displaying 01/01/testing.pdf.  I
only want testing.pdf to show up.  When the user clicks on testing.pdf, it
should go to the pdf. document.  I've aliased "opndir" in my apache.conf
file to point to the correct directory path, so the path would be
/opindir/01/02/testing.pdf. instead of /webdata/opinions/01/02/testing.pdf.

Couple of ways to do it.  In your CGI, if you are using Perl, you could use
the File::Basename to find the basename for you.

Also in your perl CGI, you could use a regular expression to extract out
the basename.

ReplaceRules should also work, although I can see a need for an extension
to the syntax.

  ReplaceRules regex !^.+/([^/]+)$!$1!

or maybe

  ReplaceRules regex !^.+/(.+)$!$1!



Bill Moseley
mailto:moseley@hank.org
Received on Fri Nov 30 17:03:59 2001