[plug] Help..how do I match /usr/local but not ./usr/local ?

James Devenish devenish at guild.uwa.edu.au
Fri Feb 27 11:27:57 WST 2004


Oops,

In message <20040227032125.GA18036 at mail.guild.uwa.edu.au>
on Fri, Feb 27, 2004 at 11:21:25AM +0800, James Devenish wrote:
>     s|(^|[^.])/usr/local|/usr|g
[...]
>     s|[^.]/usr/local|/usr|g

That is not quite right. Firstly, the need for the | will conflict with
your use of | as the expression delimiter. Furthermore, you will loose
the character that appears prior to /usr/local. You will also need to do
some "character escaping". So, to reinstate the character, you can use a
backreference in a manner somewhat like this:

     s#\(^\|[^.]\)/usr/local#\1/usr#g

If you were using Perl, you could alternatively use something like:

     s|(?![^.])/usr/local|/usr|g

(IIRC.)





More information about the plug mailing list