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

Lawrie Abbott lawrieabbott at iinet.net.au
Fri Feb 27 11:38:48 WST 2004


James Devenish wrote:

>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.)
>
>
>
>
>  
>
Thanks. That works perfectly.

Lawrie



More information about the plug mailing list