Re: Problem With Regular Expression
From: Tony George (tony.george_at_ericsson.com)
Date: 12/01/04
- Next message: Stephane CHAZELAS: "Re: start a new xterm and another program at the same time"
- Previous message: Stephane CHAZELAS: "Re: difference between the -o and || conditionals."
- In reply to: Tony George: "Problem With Regular Expression"
- Next in thread: dfrench_at_mtxia.com: "Re: Problem With Regular Expression"
- Reply: dfrench_at_mtxia.com: "Re: Problem With Regular Expression"
- Reply: rakesh sharma: "Re: Problem With Regular Expression"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 1 Dec 2004 12:31:46 -0500
Hi,
Thanks to everyone for the responses I've received to date. When I started
using the various suggestions, I realized that in fact some of my branch
names also have consecutive digits. As a result, the one-line regexps don't
always do the trick.
For example:
> echo
"/vobs/test@@/main/tony/1/pets/main/fun_123/jim_123/22/cats/main/steve_r8/2/
siamese/main/5" | sed -e 's@/main[^0-9]*[0-9]\{1,\}@@g'
> /vobs/test@@/pets/jim_123/22/cats/2/siamese
Essentially, I know that the end of a version extended pathname will be
/[0-9]\{1,\}. Also, I know that I don't have any branches that start with
numbers, but I do have many that have two or more consecutive numbers in the
branch name. What I need is a regexp that says something like:
s@/main[possibly a bunch of branches with names in the set [A-Za-z0-9_] and
separated by slashes]/[0-9]\{1,\}@@g
/main/test/1
/main/fun_123/22
/main/tony/jim_123/5
/main/fun_123/jim_123/10
Thanks again for your suggestions...
TG
"Tony George" <tony.george@ericsson.com> wrote in message
news:coipg4$e1t$1@newstree.wise.edt.ericsson.se...
> Hi,
>
> I'm using ClearCase on Solaris. ClearCase allows you to access files or
> directories anywhere in the whole source control tree using a version
> extended pathname. The problem is that sometimes it's hard to extract
just
> the basic pathname from the full version extended pathname. For example:
>
>
/vobs/test@@/main/tony/1/pets/main/fun/jim/22/cats/main/steve/2/siamese/main
> /5
>
> The actual filename I'm trying to extract here is
> /vobs/test/pets/cats/siamese. What I want to get rid of are all the
branch
> names and version numbers in between subdirectories and the final file
name.
> The problem is that when I use a basic regexp like this:
>
> > echo
>
"/vobs/test@@/main/tony/1/pets/main/fun/jim/22/cats/main/steve/2/siamese/mai
> n/5" | sed -e "s@/main.*[0-9]\{1,\}@@g"
>
> I get this:
>
> > /vobs/test@@
>
> I know it's because the default behaviour is to find the longest match
from
> the left, but I'm not quite sure how to get around it. I can pretty much
> guarantee that all branch names will start with /main and will end with at
> least 1 digit (the version number on that branch). What I can't be sure
of
> is how many nested branch levels will be in between.
>
> Any ideas?
>
> Thanks in advance...
>
> TG
>
>
>
- Next message: Stephane CHAZELAS: "Re: start a new xterm and another program at the same time"
- Previous message: Stephane CHAZELAS: "Re: difference between the -o and || conditionals."
- In reply to: Tony George: "Problem With Regular Expression"
- Next in thread: dfrench_at_mtxia.com: "Re: Problem With Regular Expression"
- Reply: dfrench_at_mtxia.com: "Re: Problem With Regular Expression"
- Reply: rakesh sharma: "Re: Problem With Regular Expression"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]