From owner-freebsd-questions Tue Mar 19 8:24:28 2002 Delivered-To: freebsd-questions@freebsd.org Received: from icarus.slightlystrange.org (icarus.slightlystrange.org [62.190.193.173]) by hub.freebsd.org (Postfix) with ESMTP id B4B6537B41E for ; Tue, 19 Mar 2002 08:24:06 -0800 (PST) Received: from danielby by icarus.slightlystrange.org with local (Exim 3.12 #1 (Debian)) id 16nMP7-0000p3-00 for ; Tue, 19 Mar 2002 16:24:05 +0000 Date: Tue, 19 Mar 2002 14:04:44 +0000 From: Daniel Bye To: freebsd-questions@freebsd.org Subject: Re: perl question Message-ID: <20020319140444.A2230@icarus.slightlystrange.org> Reply-To: dan@slightlystrange.org Mail-Followup-To: freebsd-questions@freebsd.org References: <001c01c1cee9$54b626d0$d4e18aca@melsa.net.id> <20020318200222.A6691@lastamericanempire.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020318200222.A6691@lastamericanempire.com>; from cublai@lastamericanempire.com on Mon, Mar 18, 2002 at 08:02:22PM -0700 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, Mar 18, 2002 at 08:02:22PM -0700, Zach Thompson wrote: > * ekoz [020318 19:07]: > > Hi All, > > > > I have a little problem with perl. I try to delete a few line in a file with perl. I have a following line : > > > > cs > > cs.tpkkoja > > > > I use "s/\bcs\b/ /;" to deleting the word "cs" and i don't want to deleting "cs.tpkkoja" but, i get this result : > > > > .tpkkoja > > all the word "cs" is deleted include in "cs.tpkkoja". > > Any Suggestions ? > > If the "cs" you want to delete is always on a line of itself: > > s/^cs$//; > > You could add other things like checking for leading/trailing whitespace > too. You could also try using one of the lookahead assertion forms: s/cs(?![.A-Za-z]+)//; This will match /cs/ when NOT followed by, in this case, any letter or a period. You will need to alter the regexp in the assertion to suit your own needs (the bit inside the (?!...) token) > > Zach Thompson > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message HTH Dan To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message