On Mon, May 05, 2003 at 09:46:21AM +0100, Dave Selby wrote:
> What I am trying to do is change an absolute HTML path to a relative one
> ... ie
> from
>
> file:///home/web/Desktop/current/jpegs/logo.jpeg
> to
>
> jpegs/logo.jpeg
>
> In vi the following usually works ...
> :1,$s/search text/replace text/g
Escape forward slashes (or any regex special, really) with a
backslash:
:1,$ s/file\/\/\/home\/web\/Desktop\/current\///
or if it's vim
:% s/file\/\/\/home\/web\/Desktop\/current\///
Now you know why people talk about "leaning toothpicks" when doing
regexes with filenames.
In perl, you could say
$file =~ s!file:///home/web/Desktop/current/!!
IOW you can use any delimiter you like.
> However because the search text has / in it it brings up the error
> message "trailing characters"
> I have tried quoting it in ' ' and " " same error message. - any ideas ?
>
> Also on subject of vi, Since I have a lot of pages to change and dont
> want to miss any, I used the format ..
>
> vi xxx.html xxxx.html xxxx.html .....
>
> and moved on with
> :n
>
> Is there a way to re-do my search string so I don't have to keep
> re-typing it in ?
'&' repeats the last substitution (but ignores modifiers like /g).
Personally I wouldn't use vi here, I'd use perl -pi
--
Nathan Norman - Incanus Networking mailto:nnorman@incanus.net
prepBut nI vrbLike adjHungarian! qWhat's artThe adjBig nProblem?
-- alec flett @netscape
Attachment:
pgpDdzckLcpTh.pgp
Description: PGP signature