Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Aug 2003 11:33:47 -0700 (PDT)
From:      =?ISO-8859-1?Q?Mikko_Ty=F6l=E4j=E4rvi?= <mbsd@pacbell.net>
To:        Roger Williams <root@bara.naviservers.net>
Cc:        questions@freebsd.org
Subject:   Re: Off Topic Regex Question
Message-ID:  <20030829113025.I84037@atlas.home>
In-Reply-To: <20030828075925.P26740-100000@bara.naviservers.net>
References:  <20030828075925.P26740-100000@bara.naviservers.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 28 Aug 2003, Roger Williams wrote:

> I know thins is not the place but I know one of you know this one off the
> top of your head.
>
> I have:
>
> $list = "dog 1 1 1 cat 2 1 snake 111"
> and I want to end up with:
> dog 1 cat 2 snake 1
> I thought
> $list =~ s/ \d \d/ \d/g;
> would do the trick, but that gives me:
> dog d 1 1 cat d snake d 1

I'm not sure I understand your criteria, but try something like:

  $list =~ s/(\w+\s+\d\s?)[\d\s]*/$1/g;

  $.02,
  /Mikko



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030829113025.I84037>